Passed
Push — master ( 11cfa6...a00066 )
by Brian
03:43
created
includes/admin/class-getpaid-post-types-admin.php 1 patch
Spacing   +192 added lines, -192 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
  * Post types Admin Class
@@ -21,69 +21,69 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 26
 		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28 28
 
29 29
 		// Invoice table columns.
30
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
30
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
31
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
32 32
 
33 33
 		// Items table columns.
34
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
35
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
36
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
37
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
38
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
39
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
34
+		add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100);
35
+		add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20);
36
+		add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2);
37
+		add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100);
38
+		add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100);
39
+		add_action('request', array(__CLASS__, 'reorder_items'), 100);
40 40
 
41 41
 		// Payment forms columns.
42
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
43
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
44
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
42
+		add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100);
43
+		add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2);
44
+		add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2);
45 45
 
46 46
 		// Discount table columns.
47
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
48
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
47
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
48
+		add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100);
49 49
 
50 50
 		// Deleting posts.
51
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
52
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
51
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
52
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * Post updated messages.
57 57
 	 */
58
-	public static function post_updated_messages( $messages ) {
58
+	public static function post_updated_messages($messages) {
59 59
 		global $post;
60 60
 
61 61
 		$messages['wpi_discount'] = array(
62 62
 			0   => '',
63
-			1   => __( 'Discount updated.', 'invoicing' ),
64
-			2   => __( 'Custom field updated.', 'invoicing' ),
65
-			3   => __( 'Custom field deleted.', 'invoicing' ),
66
-			4   => __( 'Discount updated.', 'invoicing' ),
67
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
68
-			6   => __( 'Discount updated.', 'invoicing' ),
69
-			7   => __( 'Discount saved.', 'invoicing' ),
70
-			8   => __( 'Discount submitted.', 'invoicing' ),
71
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
72
-			10  => __( 'Discount draft updated.', 'invoicing' ),
63
+			1   => __('Discount updated.', 'invoicing'),
64
+			2   => __('Custom field updated.', 'invoicing'),
65
+			3   => __('Custom field deleted.', 'invoicing'),
66
+			4   => __('Discount updated.', 'invoicing'),
67
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
68
+			6   => __('Discount updated.', 'invoicing'),
69
+			7   => __('Discount saved.', 'invoicing'),
70
+			8   => __('Discount submitted.', 'invoicing'),
71
+			9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
72
+			10  => __('Discount draft updated.', 'invoicing'),
73 73
 		);
74 74
 
75 75
 		$messages['wpi_payment_form'] = array(
76 76
 			0   => '',
77
-			1   => __( 'Payment Form updated.', 'invoicing' ),
78
-			2   => __( 'Custom field updated.', 'invoicing' ),
79
-			3   => __( 'Custom field deleted.', 'invoicing' ),
80
-			4   => __( 'Payment Form updated.', 'invoicing' ),
81
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
82
-			6   => __( 'Payment Form updated.', 'invoicing' ),
83
-			7   => __( 'Payment Form saved.', 'invoicing' ),
84
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
85
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
86
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
77
+			1   => __('Payment Form updated.', 'invoicing'),
78
+			2   => __('Custom field updated.', 'invoicing'),
79
+			3   => __('Custom field deleted.', 'invoicing'),
80
+			4   => __('Payment Form updated.', 'invoicing'),
81
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
82
+			6   => __('Payment Form updated.', 'invoicing'),
83
+			7   => __('Payment Form saved.', 'invoicing'),
84
+			8   => __('Payment Form submitted.', 'invoicing'),
85
+			9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
86
+			10  => __('Payment Form draft updated.', 'invoicing'),
87 87
 		);
88 88
 
89 89
 		return $messages;
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * Post row actions.
95 95
 	 */
96
-	public static function post_row_actions( $actions, $post ) {
96
+	public static function post_row_actions($actions, $post) {
97 97
 
98
-		$post = get_post( $post );
98
+		$post = get_post($post);
99 99
 
100 100
 		// We do not want to edit the default payment form.
101
-		if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
102
-			unset( $actions['trash'] );
103
-			unset( $actions['inline hide-if-no-js'] );
101
+		if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) {
102
+			unset($actions['trash']);
103
+			unset($actions['inline hide-if-no-js']);
104 104
 		}
105 105
 
106 106
 		return $actions;
@@ -109,51 +109,51 @@  discard block
 block discarded – undo
109 109
 	/**
110 110
 	 * Returns an array of invoice table columns.
111 111
 	 */
112
-	public static function invoice_columns( $columns ) {
112
+	public static function invoice_columns($columns) {
113 113
 
114 114
 		$columns = array(
115 115
 			'cb'                => $columns['cb'],
116
-			'number'            => __( 'Invoice', 'invoicing' ),
117
-			'customer'          => __( 'Customer', 'invoicing' ),
118
-			'invoice_date'      => __( 'Date', 'invoicing' ),
119
-			'amount'            => __( 'Amount', 'invoicing' ),
120
-			'recurring'         => __( 'Recurring', 'invoicing' ),
121
-			'status'            => __( 'Status', 'invoicing' ),
122
-			'wpi_actions'       => __( 'Actions', 'invoicing' ),
116
+			'number'            => __('Invoice', 'invoicing'),
117
+			'customer'          => __('Customer', 'invoicing'),
118
+			'invoice_date'      => __('Date', 'invoicing'),
119
+			'amount'            => __('Amount', 'invoicing'),
120
+			'recurring'         => __('Recurring', 'invoicing'),
121
+			'status'            => __('Status', 'invoicing'),
122
+			'wpi_actions'       => __('Actions', 'invoicing'),
123 123
 		);
124 124
 
125
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
125
+		return apply_filters('wpi_invoice_table_columns', $columns);
126 126
 	}
127 127
 
128 128
 	/**
129 129
 	 * Displays invoice table columns.
130 130
 	 */
131
-	public static function display_invoice_columns( $column_name, $post_id ) {
131
+	public static function display_invoice_columns($column_name, $post_id) {
132 132
 
133
-		$invoice = new WPInv_Invoice( $post_id );
133
+		$invoice = new WPInv_Invoice($post_id);
134 134
 
135
-		switch ( $column_name ) {
135
+		switch ($column_name) {
136 136
 
137 137
 			case 'invoice_date' :
138
-				$date_time = esc_attr( $invoice->get_created_date() );
139
-				$date      = getpaid_format_date_value( $date_time );
138
+				$date_time = esc_attr($invoice->get_created_date());
139
+				$date      = getpaid_format_date_value($date_time);
140 140
 				echo "<span title='$date_time'>$date</span>";
141 141
 				break;
142 142
 
143 143
 			case 'amount' :
144 144
 
145 145
 				$amount = $invoice->get_total();
146
-				$formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
146
+				$formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency());
147 147
 
148
-				if ( $invoice->is_refunded() ) {
149
-					$refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
148
+				if ($invoice->is_refunded()) {
149
+					$refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency());
150 150
 					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
151 151
 				} else {
152 152
 
153 153
 					$discount = $invoice->get_total_discount();
154 154
 
155
-					if ( ! empty( $discount ) ) {
156
-						$new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
155
+					if (!empty($discount)) {
156
+						$new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency());
157 157
 						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
158 158
 					} else {
159 159
 						echo $formated_amount;
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 				break;
165 165
 
166 166
 			case 'status' :
167
-				$status       = sanitize_text_field( $invoice->get_status() );
168
-				$status_label = sanitize_text_field( $invoice->get_status_nicename() );
167
+				$status       = sanitize_text_field($invoice->get_status());
168
+				$status_label = sanitize_text_field($invoice->get_status_nicename());
169 169
 
170 170
 				// If it is paid, show the gateway title.
171
-				if ( $invoice->is_paid() ) {
172
-					$gateway = sanitize_text_field( $invoice->get_gateway_title() );
173
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
171
+				if ($invoice->is_paid()) {
172
+					$gateway = sanitize_text_field($invoice->get_gateway_title());
173
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway);
174 174
 
175 175
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
176 176
 				} else {
@@ -178,22 +178,22 @@  discard block
 block discarded – undo
178 178
 				}
179 179
 
180 180
 				// If it is not paid, display the overdue and view status.
181
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
181
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
182 182
 
183 183
 					// Invoice view status.
184
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
185
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
184
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
185
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
186 186
 					} else {
187
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
187
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
188 188
 					}
189 189
 
190 190
 					// Display the overview status.
191
-					if ( wpinv_get_option( 'overdue_active' ) ) {
191
+					if (wpinv_get_option('overdue_active')) {
192 192
 						$due_date = $invoice->get_due_date();
193
-						$fomatted = getpaid_format_date( $due_date );
193
+						$fomatted = getpaid_format_date($due_date);
194 194
 
195
-						if ( ! empty( $fomatted ) ) {
196
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
195
+						if (!empty($fomatted)) {
196
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
197 197
 							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
198 198
 						}
199 199
 					}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 			case 'recurring':
206 206
 
207
-				if ( $invoice->is_recurring() ) {
207
+				if ($invoice->is_recurring()) {
208 208
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
209 209
 				} else {
210 210
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 
214 214
 			case 'number' :
215 215
 
216
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
217
-				$invoice_number  = sanitize_text_field( $invoice->get_number() );
218
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
216
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
217
+				$invoice_number  = sanitize_text_field($invoice->get_number());
218
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
219 219
 
220 220
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
221 221
 
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 	
226 226
 				$customer_name = $invoice->get_user_full_name();
227 227
 	
228
-				if ( empty( $customer_name ) ) {
228
+				if (empty($customer_name)) {
229 229
 					$customer_name = $invoice->get_email();
230 230
 				}
231 231
 	
232
-				if ( ! empty( $customer_name ) ) {
233
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
234
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
232
+				if (!empty($customer_name)) {
233
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
234
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
235 235
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
236 236
 				} else {
237 237
 					echo '<div>&mdash;</div>';
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 
242 242
 			case 'wpi_actions' :
243 243
 
244
-				if ( $invoice->is_draft() ) {
244
+				if ($invoice->is_draft()) {
245 245
 					return;
246 246
 				}
247 247
 
248
-				$url    = esc_url( $invoice->get_view_url() );
249
-				$print  = esc_attr__( 'Print invoice', 'invoicing' );
248
+				$url    = esc_url($invoice->get_view_url());
249
+				$print  = esc_attr__('Print invoice', 'invoicing');
250 250
 				echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
251 251
 
252 252
 				$url    = esc_url(
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 					)
263 263
 				);
264 264
 
265
-				$send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
265
+				$send = esc_attr__('Send invoice to customer', 'invoicing');
266 266
 				echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
267 267
 
268 268
 				break;
@@ -273,50 +273,50 @@  discard block
 block discarded – undo
273 273
 	/**
274 274
 	 * Returns an array of payment forms table columns.
275 275
 	 */
276
-	public static function payment_form_columns( $columns ) {
276
+	public static function payment_form_columns($columns) {
277 277
 
278 278
 		$columns = array(
279 279
 			'cb'                => $columns['cb'],
280
-			'title'             => __( 'Name', 'invoicing' ),
281
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
282
-			'earnings'          => __( 'Revenue', 'invoicing' ),
283
-			'refunds'           => __( 'Refunded', 'invoicing' ),
284
-			'items'             => __( 'Items', 'invoicing' ),
285
-			'date'              => __( 'Date', 'invoicing' ),
280
+			'title'             => __('Name', 'invoicing'),
281
+			'shortcode'         => __('Shortcode', 'invoicing'),
282
+			'earnings'          => __('Revenue', 'invoicing'),
283
+			'refunds'           => __('Refunded', 'invoicing'),
284
+			'items'             => __('Items', 'invoicing'),
285
+			'date'              => __('Date', 'invoicing'),
286 286
 		);
287 287
 
288
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
288
+		return apply_filters('wpi_payment_form_table_columns', $columns);
289 289
 
290 290
 	}
291 291
 
292 292
 	/**
293 293
 	 * Displays payment form table columns.
294 294
 	 */
295
-	public static function display_payment_form_columns( $column_name, $post_id ) {
295
+	public static function display_payment_form_columns($column_name, $post_id) {
296 296
 
297 297
 		// Retrieve the payment form.
298
-		$form = new GetPaid_Payment_Form( $post_id );
298
+		$form = new GetPaid_Payment_Form($post_id);
299 299
 
300
-		switch ( $column_name ) {
300
+		switch ($column_name) {
301 301
 
302 302
 			case 'earnings' :
303
-				echo wpinv_price( wpinv_format_amount( $form->get_earned() ) );
303
+				echo wpinv_price(wpinv_format_amount($form->get_earned()));
304 304
 				break;
305 305
 
306 306
 			case 'refunds' :
307
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
307
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
308 308
 				break;
309 309
 
310 310
 			case 'refunds' :
311
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
311
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
312 312
 				break;
313 313
 
314 314
 			case 'shortcode' :
315 315
 
316
-				if ( $form->is_default() ) {
316
+				if ($form->is_default()) {
317 317
 					echo '&mdash;';
318 318
 				} else {
319
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
319
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
320 320
 				}
321 321
 
322 322
 				break;
@@ -325,29 +325,29 @@  discard block
 block discarded – undo
325 325
 
326 326
 				$items = $form->get_items();
327 327
 
328
-				if ( $form->is_default() || empty( $items ) ) {
328
+				if ($form->is_default() || empty($items)) {
329 329
 					echo '&mdash;';
330 330
 					return;
331 331
 				}
332 332
 
333 333
 				$_items = array();
334 334
 
335
-				foreach ( $items as $item ) {
335
+				foreach ($items as $item) {
336 336
 					$url = $item->get_edit_url();
337 337
 
338
-					if ( empty( $url ) ) {
339
-						$_items[] = sanitize_text_field( $item->get_name() );
338
+					if (empty($url)) {
339
+						$_items[] = sanitize_text_field($item->get_name());
340 340
 					} else {
341 341
 						$_items[] = sprintf(
342 342
 							'<a href="%s">%s</a>',
343
-							esc_url( $url ),
344
-							sanitize_text_field( $item->get_name() )
343
+							esc_url($url),
344
+							sanitize_text_field($item->get_name())
345 345
 						);
346 346
 					}
347 347
 
348 348
 				}
349 349
 
350
-				echo implode( '<br>', $_items );
350
+				echo implode('<br>', $_items);
351 351
 
352 352
 				break;
353 353
 
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
 	/**
359 359
 	 * Filters post states.
360 360
 	 */
361
-	public static function filter_payment_form_state( $post_states, $post ) {
361
+	public static function filter_payment_form_state($post_states, $post) {
362 362
 
363
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
364
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
363
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
364
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
365 365
 		}
366 366
 	
367 367
 		return $post_states;
@@ -371,35 +371,35 @@  discard block
 block discarded – undo
371 371
 	/**
372 372
 	 * Returns an array of coupon table columns.
373 373
 	 */
374
-	public static function discount_columns( $columns ) {
374
+	public static function discount_columns($columns) {
375 375
 
376 376
 		$columns = array(
377 377
 			'cb'                => $columns['cb'],
378
-			'title'             => __( 'Name', 'invoicing' ),
379
-			'code'              => __( 'Code', 'invoicing' ),
380
-			'amount'            => __( 'Amount', 'invoicing' ),
381
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
382
-			'start_date'        => __( 'Start Date', 'invoicing' ),
383
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
378
+			'title'             => __('Name', 'invoicing'),
379
+			'code'              => __('Code', 'invoicing'),
380
+			'amount'            => __('Amount', 'invoicing'),
381
+			'usage'             => __('Usage / Limit', 'invoicing'),
382
+			'start_date'        => __('Start Date', 'invoicing'),
383
+			'expiry_date'       => __('Expiry Date', 'invoicing'),
384 384
 		);
385 385
 
386
-		return apply_filters( 'wpi_discount_table_columns', $columns );
386
+		return apply_filters('wpi_discount_table_columns', $columns);
387 387
 	}
388 388
 
389 389
 	/**
390 390
 	 * Filters post states.
391 391
 	 */
392
-	public static function filter_discount_state( $post_states, $post ) {
392
+	public static function filter_discount_state($post_states, $post) {
393 393
 
394
-		if ( 'wpi_discount' == $post->post_type ) {
394
+		if ('wpi_discount' == $post->post_type) {
395 395
 
396
-			$discount = new WPInv_Discount( $post );
396
+			$discount = new WPInv_Discount($post);
397 397
 
398 398
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
399 399
 
400
-			if ( $status != 'publish' ) {
400
+			if ($status != 'publish') {
401 401
 				return array(
402
-					'discount_status' => wpinv_discount_status( $status ),
402
+					'discount_status' => wpinv_discount_status($status),
403 403
 				);
404 404
 			}
405 405
 
@@ -414,30 +414,30 @@  discard block
 block discarded – undo
414 414
 	/**
415 415
 	 * Returns an array of items table columns.
416 416
 	 */
417
-	public static function item_columns( $columns ) {
417
+	public static function item_columns($columns) {
418 418
 
419 419
 		$columns = array(
420 420
 			'cb'                => $columns['cb'],
421
-			'title'             => __( 'Name', 'invoicing' ),
422
-			'price'             => __( 'Price', 'invoicing' ),
423
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
424
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
425
-			'type'              => __( 'Type', 'invoicing' ),
426
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
421
+			'title'             => __('Name', 'invoicing'),
422
+			'price'             => __('Price', 'invoicing'),
423
+			'vat_rule'          => __('VAT rule', 'invoicing'),
424
+			'vat_class'         => __('VAT class', 'invoicing'),
425
+			'type'              => __('Type', 'invoicing'),
426
+			'shortcode'         => __('Shortcode', 'invoicing'),
427 427
 		);
428 428
 
429
-		if ( ! wpinv_use_taxes() ) {
430
-			unset( $columns['vat_rule'] );
431
-			unset( $columns['vat_class'] );
429
+		if (!wpinv_use_taxes()) {
430
+			unset($columns['vat_rule']);
431
+			unset($columns['vat_class']);
432 432
 		}
433 433
 
434
-		return apply_filters( 'wpi_item_table_columns', $columns );
434
+		return apply_filters('wpi_item_table_columns', $columns);
435 435
 	}
436 436
 
437 437
 	/**
438 438
 	 * Returns an array of sortable items table columns.
439 439
 	 */
440
-	public static function sortable_item_columns( $columns ) {
440
+	public static function sortable_item_columns($columns) {
441 441
 
442 442
 		return array_merge(
443 443
 			$columns,
@@ -454,49 +454,49 @@  discard block
 block discarded – undo
454 454
 	/**
455 455
 	 * Displays items table columns.
456 456
 	 */
457
-	public static function display_item_columns( $column_name, $post_id ) {
457
+	public static function display_item_columns($column_name, $post_id) {
458 458
  
459
-		$item = new WPInv_Item( $post_id );
459
+		$item = new WPInv_Item($post_id);
460 460
 
461
-		switch ( $column_name ) {
461
+		switch ($column_name) {
462 462
 
463 463
 			case 'price' :
464 464
 
465
-				if ( ! $item->is_recurring() ) {
465
+				if (!$item->is_recurring()) {
466 466
 					echo $item->get_the_price();
467 467
 					break;
468 468
 				}
469 469
 
470 470
 				$price = wp_sprintf(
471
-					__( '%s / %s', 'invoicing' ),
471
+					__('%s / %s', 'invoicing'),
472 472
 					$item->get_the_price(),
473
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
473
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
474 474
 				);
475 475
 
476
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
476
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
477 477
 					echo $price;
478 478
 					break;
479 479
 				}
480 480
 
481 481
 				echo $item->get_the_initial_price();
482 482
 
483
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
483
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
484 484
 				break;
485 485
 
486 486
 			case 'vat_rule' :
487
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
487
+				echo getpaid_get_tax_rule_label($item->get_vat_rule());
488 488
 				break;
489 489
 
490 490
 			case 'vat_class' :
491
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
491
+				echo getpaid_get_tax_class_label($item->get_vat_class());
492 492
 				break;
493 493
 
494 494
 			case 'shortcode' :
495
-				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
495
+				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
496 496
 				break;
497 497
 
498 498
 			case 'type' :
499
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
499
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
500 500
 				break;
501 501
 
502 502
 		}
@@ -506,21 +506,21 @@  discard block
 block discarded – undo
506 506
 	/**
507 507
 	 * Lets users filter items using taxes.
508 508
 	 */
509
-	public static function add_item_filters( $post_type ) {
509
+	public static function add_item_filters($post_type) {
510 510
 
511 511
 		// Abort if we're not dealing with items.
512
-		if ( $post_type != 'wpi_item' ) {
512
+		if ($post_type != 'wpi_item') {
513 513
 			return;
514 514
 		}
515 515
 
516 516
 		// Filter by vat rules.
517
-		if ( wpinv_use_taxes() ) {
517
+		if (wpinv_use_taxes()) {
518 518
 	
519 519
 			// Sanitize selected vat rule.
520 520
 			$vat_rule   = '';
521 521
 			$vat_rules  = getpaid_get_tax_rules();
522
-			if ( isset( $_GET['vat_rule'] ) ) {
523
-				$vat_rule   =  $_GET['vat_rule'];
522
+			if (isset($_GET['vat_rule'])) {
523
+				$vat_rule = $_GET['vat_rule'];
524 524
 			}
525 525
 
526 526
 			// Filter by VAT rule.
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
 				array(
529 529
 					'options'          => array_merge(
530 530
 						array(
531
-							'' => __( 'All VAT rules', 'invoicing' )
531
+							'' => __('All VAT rules', 'invoicing')
532 532
 						),
533 533
 						$vat_rules
534 534
 					),
535 535
 					'name'             => 'vat_rule',
536 536
 					'id'               => 'vat_rule',
537
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
537
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
538 538
 					'show_option_all'  => false,
539 539
 					'show_option_none' => false,
540 540
 					'class'            => 'gdmbx2-text-medium',
@@ -546,21 +546,21 @@  discard block
 block discarded – undo
546 546
 			// Sanitize selected vat rule.
547 547
 			$vat_class   = '';
548 548
 			$vat_classes = getpaid_get_tax_classes();
549
-			if ( isset( $_GET['vat_class'] ) ) {
550
-				$vat_class   =  $_GET['vat_class'];
549
+			if (isset($_GET['vat_class'])) {
550
+				$vat_class = $_GET['vat_class'];
551 551
 			}
552 552
 
553 553
 			echo wpinv_html_select(
554 554
 				array(
555 555
 					'options'          => array_merge(
556 556
 						array(
557
-							'' => __( 'All VAT classes', 'invoicing' )
557
+							'' => __('All VAT classes', 'invoicing')
558 558
 						),
559 559
 						$vat_classes
560 560
 					),
561 561
 					'name'             => 'vat_class',
562 562
 					'id'               => 'vat_class',
563
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
563
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
564 564
 					'show_option_all'  => false,
565 565
 					'show_option_none' => false,
566 566
 					'class'            => 'gdmbx2-text-medium',
@@ -570,22 +570,22 @@  discard block
 block discarded – undo
570 570
 		}
571 571
 
572 572
 		// Filter by item type.
573
-		$type   = '';
574
-		if ( isset( $_GET['type'] ) ) {
575
-			$type   =  $_GET['type'];
573
+		$type = '';
574
+		if (isset($_GET['type'])) {
575
+			$type = $_GET['type'];
576 576
 		}
577 577
 
578 578
 		echo wpinv_html_select(
579 579
 			array(
580 580
 				'options'          => array_merge(
581 581
 					array(
582
-						'' => __( 'All item types', 'invoicing' )
582
+						'' => __('All item types', 'invoicing')
583 583
 					),
584 584
 					wpinv_get_item_types()
585 585
 				),
586 586
 				'name'             => 'type',
587 587
 				'id'               => 'type',
588
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
588
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
589 589
 				'show_option_all'  => false,
590 590
 				'show_option_none' => false,
591 591
 				'class'            => 'gdmbx2-text-medium',
@@ -597,45 +597,45 @@  discard block
 block discarded – undo
597 597
 	/**
598 598
 	 * Filters the item query.
599 599
 	 */
600
-	public static function filter_item_query( $query ) {
600
+	public static function filter_item_query($query) {
601 601
 
602 602
 		// modify the query only if it admin and main query.
603
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
603
+		if (!(is_admin() && $query->is_main_query())) { 
604 604
 			return $query;
605 605
 		}
606 606
 
607 607
 		// we want to modify the query for our items.
608
-		if ( 'wpi_item' != $query->query['post_type'] ){
608
+		if ('wpi_item' != $query->query['post_type']) {
609 609
 			return $query;
610 610
 		}
611 611
 
612
-		if ( empty( $query->query_vars['meta_query'] ) ) {
612
+		if (empty($query->query_vars['meta_query'])) {
613 613
 			$query->query_vars['meta_query'] = array();
614 614
 		}
615 615
 
616 616
 		// Filter vat rule type
617
-        if ( ! empty( $_GET['vat_rule'] ) ) {
617
+        if (!empty($_GET['vat_rule'])) {
618 618
             $query->query_vars['meta_query'][] = array(
619 619
                 'key'     => '_wpinv_vat_rule',
620
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
620
+                'value'   => sanitize_text_field($_GET['vat_rule']),
621 621
                 'compare' => '='
622 622
             );
623 623
         }
624 624
 
625 625
         // Filter vat class
626
-        if ( ! empty( $_GET['vat_class'] ) ) {
626
+        if (!empty($_GET['vat_class'])) {
627 627
             $query->query_vars['meta_query'][] = array(
628 628
                 'key'     => '_wpinv_vat_class',
629
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
629
+                'value'   => sanitize_text_field($_GET['vat_class']),
630 630
                 'compare' => '='
631 631
             );
632 632
         }
633 633
 
634 634
         // Filter item type
635
-        if ( ! empty( $_GET['type'] ) ) {
635
+        if (!empty($_GET['type'])) {
636 636
             $query->query_vars['meta_query'][] = array(
637 637
                 'key'     => '_wpinv_type',
638
-                'value'   => sanitize_text_field( $_GET['type'] ),
638
+                'value'   => sanitize_text_field($_GET['type']),
639 639
                 'compare' => '='
640 640
             );
641 641
 		}
@@ -645,15 +645,15 @@  discard block
 block discarded – undo
645 645
 	/**
646 646
 	 * Reorders items.
647 647
 	 */
648
-	public static function reorder_items( $vars ) {
648
+	public static function reorder_items($vars) {
649 649
 		global $typenow;
650 650
 
651
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
651
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
652 652
 			return $vars;
653 653
 		}
654 654
 
655 655
 		// By item type.
656
-		if ( 'type' == $vars['orderby'] ) {
656
+		if ('type' == $vars['orderby']) {
657 657
 			return array_merge(
658 658
 				$vars,
659 659
 				array(
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 		}
665 665
 
666 666
 		// By vat class.
667
-		if ( 'vat_class' == $vars['orderby'] ) {
667
+		if ('vat_class' == $vars['orderby']) {
668 668
 			return array_merge(
669 669
 				$vars,
670 670
 				array(
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 		}
676 676
 
677 677
 		// By vat rule.
678
-		if ( 'vat_rule' == $vars['orderby'] ) {
678
+		if ('vat_rule' == $vars['orderby']) {
679 679
 			return array_merge(
680 680
 				$vars,
681 681
 				array(
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 		}
687 687
 
688 688
 		// By price.
689
-		if ( 'price' == $vars['orderby'] ) {
689
+		if ('price' == $vars['orderby']) {
690 690
 			return array_merge(
691 691
 				$vars,
692 692
 				array(
@@ -703,27 +703,27 @@  discard block
 block discarded – undo
703 703
 	/**
704 704
 	 * Fired when deleting a post.
705 705
 	 */
706
-	public static function delete_post( $post_id ) {
706
+	public static function delete_post($post_id) {
707 707
 
708
-		switch ( get_post_type( $post_id ) ) {
708
+		switch (get_post_type($post_id)) {
709 709
 
710 710
 			case 'wpi_item' :
711
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
711
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
712 712
 				break;
713 713
 
714 714
 			case 'wpi_payment_form' :
715
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
715
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
716 716
 				break;
717 717
 
718 718
 			case 'wpi_discount' :
719
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
719
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
720 720
 				break;
721 721
 
722 722
 			case 'wpi_invoice' :
723
-				$invoice = new WPInv_Invoice( $post_id );
724
-				do_action( "getpaid_before_delete_invoice", $invoice );
725
-				$invoice->get_data_store()->delete_items( $invoice );
726
-				$invoice->get_data_store()->delete_special_fields( $invoice );
723
+				$invoice = new WPInv_Invoice($post_id);
724
+				do_action("getpaid_before_delete_invoice", $invoice);
725
+				$invoice->get_data_store()->delete_items($invoice);
726
+				$invoice->get_data_store()->delete_special_fields($invoice);
727 727
 				break;
728 728
 		}
729 729
 	}
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-vat.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,26 +21,26 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         echo "<div class='bsui' style='max-width: 600px;padding-top: 10px;'>";
30 30
 
31
-        do_action( 'wpinv_item_before_vat_metabox', $item );
31
+        do_action('wpinv_item_before_vat_metabox', $item);
32 32
 
33 33
         // Output the vat rules settings.
34
-        do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item );
35
-        self::output_vat_rules( $item );
36
-        do_action( 'wpinv_item_vat_metabox_vat_rules', $item );
34
+        do_action('wpinv_item_vat_metabox_before_vat_rules', $item);
35
+        self::output_vat_rules($item);
36
+        do_action('wpinv_item_vat_metabox_vat_rules', $item);
37 37
 
38 38
         // Output vat class settings.
39
-        do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item );
40
-        self::output_vat_classes( $item );
41
-        do_action( 'wpinv_item_vat_metabox_vat_class', $item );
39
+        do_action('wpinv_item_vat_metabox_before_vat_rules', $item);
40
+        self::output_vat_classes($item);
41
+        do_action('wpinv_item_vat_metabox_vat_class', $item);
42 42
 
43
-        do_action( 'wpinv_item_vat_metabox', $item );
43
+        do_action('wpinv_item_vat_metabox', $item);
44 44
 
45 45
         echo '</div>';
46 46
     }
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param WPInv_Item $item
52 52
 	 */
53
-    public static function output_vat_rules( $item ) {
53
+    public static function output_vat_rules($item) {
54 54
         ?>
55 55
 
56 56
             <div class="wpinv_vat_rules">
57 57
 
58 58
                 <div class="form-group row">
59 59
                     <label for="wpinv_vat_rules" class="col-sm-3 col-form-label">
60
-                        <?php _e( 'VAT Rule', 'invoicing' );?>
60
+                        <?php _e('VAT Rule', 'invoicing'); ?>
61 61
                     </label>
62 62
                     <div class="col-sm-8">
63 63
                         <?php
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
                                 array(
66 66
                                     'id'               => 'wpinv_vat_rules',
67 67
                                     'name'             => 'wpinv_vat_rules',
68
-                                    'placeholder'      => __( 'Select VAT rule', 'invoicing' ),
69
-                                    'value'            => $item->get_vat_rule( 'edit' ),
68
+                                    'placeholder'      => __('Select VAT rule', 'invoicing'),
69
+                                    'value'            => $item->get_vat_rule('edit'),
70 70
                                     'select2'          => true,
71 71
                                     'data-allow-clear' => 'false',
72 72
                                     'no_wrap'          => true,
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                         ?>
77 77
                     </div>
78 78
                     <div class="col-sm-1 pt-2 pl-0">
79
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country. <br><br>If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?>"></span>
79
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country. <br><br>If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?>"></span>
80 80
                     </div>
81 81
                 </div>
82 82
 
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @param WPInv_Item $item
93 93
 	 */
94
-    public static function output_vat_classes( $item ) {
94
+    public static function output_vat_classes($item) {
95 95
         ?>
96 96
 
97 97
             <div class="wpinv_vat_classes">
98 98
 
99 99
                 <div class="form-group row">
100 100
                     <label for="wpinv_vat_class" class="col-sm-3 col-form-label">
101
-                        <?php _e( 'VAT Class', 'invoicing' );?>
101
+                        <?php _e('VAT Class', 'invoicing'); ?>
102 102
                     </label>
103 103
                     <div class="col-sm-8">
104 104
                         <?php
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
                                 array(
107 107
                                     'id'               => 'wpinv_vat_class',
108 108
                                     'name'             => 'wpinv_vat_class',
109
-                                    'placeholder'      => __( 'Select VAT class', 'invoicing' ),
110
-                                    'value'            => $item->get_vat_class( 'edit' ),
109
+                                    'placeholder'      => __('Select VAT class', 'invoicing'),
110
+                                    'value'            => $item->get_vat_class('edit'),
111 111
                                     'select2'          => true,
112 112
                                     'data-allow-clear' => 'false',
113 113
                                     'no_wrap'          => true,
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                         ?>
118 118
                     </div>
119 119
                     <div class="col-sm-1 pt-2 pl-0">
120
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the VAT rate class to use for this invoice item', 'invoicing' ); ?>"></span>
120
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the VAT rate class to use for this invoice item', 'invoicing'); ?>"></span>
121 121
                     </div>
122 122
                 </div>
123 123
 
Please login to merge, or discard this patch.
includes/wpinv-tax-functions.php 1 patch
Spacing   +142 added lines, -142 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
  * Returns the tax class objet.
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
  * 
21 21
  * @return bool
22 22
  */
23
-function getpaid_is_eu_state( $country ) {
24
-    return WPInv_EUVat::is_eu_state( $country );
23
+function getpaid_is_eu_state($country) {
24
+    return WPInv_EUVat::is_eu_state($country);
25 25
 }
26 26
 
27 27
 /**
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
  * 
30 30
  * @return bool
31 31
  */
32
-function getpaid_is_gst_country( $country ) {
33
-    return WPInv_EUVat::is_gst_country( $country );
32
+function getpaid_is_gst_country($country) {
33
+    return WPInv_EUVat::is_gst_country($country);
34 34
 }
35 35
 
36 36
 /**
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function wpinv_use_taxes() {
51 51
 
52
-    $ret = wpinv_get_option( 'enable_taxes', false );
53
-    return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) );
52
+    $ret = wpinv_get_option('enable_taxes', false);
53
+    return (bool) apply_filters('wpinv_use_taxes', !empty($ret));
54 54
 
55 55
 }
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @param WPInv_Invoice $invoice
61 61
  * @return bool
62 62
  */
63
-function wpinv_is_invoice_taxable( $invoice ) {
63
+function wpinv_is_invoice_taxable($invoice) {
64 64
     return $invoice->is_taxable();
65 65
 }
66 66
 
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
  * @param string $country
71 71
  * @return bool
72 72
  */
73
-function wpinv_is_country_taxable( $country ) {
74
-    $is_eu     = getpaid_is_eu_state( $country );
75
-    $is_exempt = $is_eu && $country == wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat();
73
+function wpinv_is_country_taxable($country) {
74
+    $is_eu     = getpaid_is_eu_state($country);
75
+    $is_exempt = $is_eu && $country == wpinv_is_base_country($country) && wpinv_same_country_exempt_vat();
76 76
     
77
-    return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); 
77
+    return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); 
78 78
 
79 79
 }
80 80
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
  * @param WPInv_Item|GetPaid_Form_Item $item
85 85
  * @return bool
86 86
  */
87
-function wpinv_is_item_taxable( $item ) {
87
+function wpinv_is_item_taxable($item) {
88 88
     return '_exempt' != $item->get_vat_rule();
89 89
 }
90 90
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
  * @return bool
95 95
  */
96 96
 function wpinv_use_store_address_as_tax_base() {
97
-    $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base';
98
-    return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base );
97
+    $use_base = wpinv_get_option('tax_base', 'billing') == 'base';
98
+    return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base);
99 99
 }
100 100
 
101 101
 /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
  * @return bool
105 105
  */
106 106
 function wpinv_prices_include_tax() {
107
-    $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes';
108
-    return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive );
107
+    $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes';
108
+    return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive);
109 109
 }
110 110
 
111 111
 /**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
  * @return bool
115 115
  */
116 116
 function wpinv_round_tax_per_tax_rate() {
117
-    $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 );
118
-    return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) );
117
+    $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1);
118
+    return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding));
119 119
 }
120 120
 
121 121
 /**
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
  * @return bool
125 125
  */
126 126
 function wpinv_display_individual_tax_rates() {
127
-    $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual';
128
-    return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual );
127
+    $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual';
128
+    return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual);
129 129
 }
130 130
 
131 131
 /**
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
  * @return float
135 135
  */
136 136
 function wpinv_get_default_tax_rate() {
137
-    $rate = wpinv_get_option( 'tax_rate', false );
138
-    return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) );
137
+    $rate = wpinv_get_option('tax_rate', false);
138
+    return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate));
139 139
 }
140 140
 
141 141
 /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  * @return bool
145 145
  */
146 146
 function wpinv_same_country_exempt_vat() {
147
-    return 'no' == wpinv_get_option( 'vat_same_country_rule' );
147
+    return 'no' == wpinv_get_option('vat_same_country_rule');
148 148
 }
149 149
 
150 150
 /**
@@ -164,28 +164,28 @@  discard block
 block discarded – undo
164 164
  * @param string $state
165 165
  * @return array
166 166
  */
167
-function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) {
167
+function getpaid_get_item_tax_rates($item, $country = '', $state = '') {
168 168
 
169 169
     // Abort if the item is not taxable.
170
-    if ( ! wpinv_is_item_taxable( $item ) ) {
170
+    if (!wpinv_is_item_taxable($item)) {
171 171
         return array();
172 172
     }
173 173
 
174 174
     // Maybe use the store address.
175
-    if ( wpinv_use_store_address_as_tax_base() ) {
175
+    if (wpinv_use_store_address_as_tax_base()) {
176 176
         $country = wpinv_get_default_country();
177 177
         $state   = wpinv_get_default_state();
178 178
     }
179 179
 
180 180
     // Retrieve tax rates.
181
-    $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state );
181
+    $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state);
182 182
 
183 183
     // Fallback to the default tax rates if non were found.
184
-    if ( empty( $tax_rates ) ) {
184
+    if (empty($tax_rates)) {
185 185
         $tax_rates = GetPaid_Tax::get_default_tax_rates();
186 186
     }
187 187
 
188
-    return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state );
188
+    return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state);
189 189
 }
190 190
 
191 191
 /**
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
  * @param array $rates
196 196
  * @return array
197 197
  */
198
-function getpaid_calculate_item_taxes( $amount, $rates ) {
198
+function getpaid_calculate_item_taxes($amount, $rates) {
199 199
 
200 200
     $is_inclusive = wpinv_prices_include_tax();
201
-    $taxes        = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive );
201
+    $taxes        = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive);
202 202
 
203
-    return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates );
203
+    return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates);
204 204
 }
205 205
 
206 206
 /**
@@ -212,17 +212,17 @@  discard block
 block discarded – undo
212 212
  * @param float $recurring_tax_amount
213 213
  * @return array
214 214
  */
215
-function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
215
+function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) {
216 216
 
217
-    $initial_tax   = $tax_amount;
217
+    $initial_tax = $tax_amount;
218 218
 	$recurring_tax = 0;
219 219
 
220
-    if ( $item->is_recurring() ) {
220
+    if ($item->is_recurring()) {
221 221
 		$recurring_tax = $recurring_tax_amount;
222 222
 	}
223 223
 
224 224
 	return array(
225
-		'name'          => sanitize_text_field( $tax_name ),
225
+		'name'          => sanitize_text_field($tax_name),
226 226
 		'initial_tax'   => $initial_tax,
227 227
 		'recurring_tax' => $recurring_tax,
228 228
     );
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
  * @param string $vat_number
236 236
  * @return string
237 237
  */
238
-function wpinv_sanitize_vat_number( $vat_number ) {
239
-    return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
238
+function wpinv_sanitize_vat_number($vat_number) {
239
+    return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
240 240
 }
241 241
 
242 242
 /**
@@ -245,22 +245,22 @@  discard block
 block discarded – undo
245 245
  * @param string $vat_number
246 246
  * @return bool
247 247
  */
248
-function wpinv_regex_validate_vat_number( $vat_number ) {
248
+function wpinv_regex_validate_vat_number($vat_number) {
249 249
 
250
-    $country    = substr( $vat_number, 0, 2 );
251
-    $vatin      = substr( $vat_number, 2 );
252
-    $regexes    = wpinv_get_data( 'vat-number-regexes' );
250
+    $country    = substr($vat_number, 0, 2);
251
+    $vatin      = substr($vat_number, 2);
252
+    $regexes    = wpinv_get_data('vat-number-regexes');
253 253
 
254
-    if ( isset( $regexes[ $country ] ) ) {
254
+    if (isset($regexes[$country])) {
255 255
 
256
-        $regex = $regexes[ $country ];
256
+        $regex = $regexes[$country];
257 257
         $regex = '/^(?:' . $regex . ')$/';
258
-        return 1 === preg_match( $regex, $vatin );
258
+        return 1 === preg_match($regex, $vatin);
259 259
 
260 260
     }
261 261
 
262 262
     // Not an EU state, use filters to validate the number.
263
-    return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number );
263
+    return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number);
264 264
 }
265 265
 
266 266
 /**
@@ -269,29 +269,29 @@  discard block
 block discarded – undo
269 269
  * @param string $vat_number
270 270
  * @return bool
271 271
  */
272
-function wpinv_vies_validate_vat_number( $vat_number ) {
272
+function wpinv_vies_validate_vat_number($vat_number) {
273 273
 
274
-    $country    = substr( $vat_number, 0, 2 );
275
-    $vatin      = substr( $vat_number, 2 );
274
+    $country    = substr($vat_number, 0, 2);
275
+    $vatin      = substr($vat_number, 2);
276 276
 
277 277
     $url        = add_query_arg(
278 278
         array(
279
-            'ms'  => urlencode( $country ),
280
-            'iso' => urlencode( $country ),
281
-            'vat' => urlencode( $vatin ),
279
+            'ms'  => urlencode($country),
280
+            'iso' => urlencode($country),
281
+            'vat' => urlencode($vatin),
282 282
         ),
283 283
         'http://ec.europa.eu/taxation_customs/vies/viesquer.do'
284 284
     );
285 285
 
286
-    $response   = wp_remote_get( $url );
287
-    $response   = wp_remote_retrieve_body( $response );
286
+    $response   = wp_remote_get($url);
287
+    $response   = wp_remote_retrieve_body($response);
288 288
 
289 289
     // Fallback gracefully if the VIES website is down.
290
-    if ( empty( $response ) ) {
290
+    if (empty($response)) {
291 291
         return true;
292 292
     }
293 293
 
294
-    return 1 !== preg_match( '/invalid VAT number/i', $response );
294
+    return 1 !== preg_match('/invalid VAT number/i', $response);
295 295
 
296 296
 }
297 297
 
@@ -302,23 +302,23 @@  discard block
 block discarded – undo
302 302
  * @param string $country
303 303
  * @return bool
304 304
  */
305
-function wpinv_validate_vat_number( $vat_number, $country ) {
305
+function wpinv_validate_vat_number($vat_number, $country) {
306 306
     
307 307
     // Abort if we are not validating this.
308
-    if ( ! wpinv_should_validate_vat_number() || empty( $vat_number ) ) {
308
+    if (!wpinv_should_validate_vat_number() || empty($vat_number)) {
309 309
         return true;
310 310
     }
311 311
 
312 312
     // In case the vat number does not have a country code...
313
-    $vat_number = wpinv_sanitize_vat_number( $vat_number );
314
-    $_country   = substr( $vat_number, 0, 2 );
315
-    $_country   = $_country == wpinv_country_name( $_country );
313
+    $vat_number = wpinv_sanitize_vat_number($vat_number);
314
+    $_country   = substr($vat_number, 0, 2);
315
+    $_country   = $_country == wpinv_country_name($_country);
316 316
 
317
-    if ( $_country ) {
318
-        $vat_number = strtoupper( $country ) . $vat_number;
317
+    if ($_country) {
318
+        $vat_number = strtoupper($country) . $vat_number;
319 319
     }
320 320
 
321
-    return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number );
321
+    return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number);
322 322
 }
323 323
 
324 324
 /**
@@ -327,40 +327,40 @@  discard block
 block discarded – undo
327 327
  * @return bool
328 328
  */
329 329
 function wpinv_should_validate_vat_number() {
330
-    $validate = wpinv_get_option( 'validate_vat_number' );
331
-	return ! empty( $validate );
330
+    $validate = wpinv_get_option('validate_vat_number');
331
+	return !empty($validate);
332 332
 }
333 333
 
334
-function wpinv_sales_tax_for_year( $year = null ) {
335
-    return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) );
334
+function wpinv_sales_tax_for_year($year = null) {
335
+    return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year)));
336 336
 }
337 337
 
338
-function wpinv_get_sales_tax_for_year( $year = null ) {
338
+function wpinv_get_sales_tax_for_year($year = null) {
339 339
     global $wpdb;
340 340
 
341 341
     // Start at zero
342 342
     $tax = 0;
343 343
 
344
-    if ( ! empty( $year ) ) {
344
+    if (!empty($year)) {
345 345
         $args = array(
346 346
             'post_type'      => 'wpi_invoice',
347
-            'post_status'    => array( 'publish' ),
347
+            'post_status'    => array('publish'),
348 348
             'posts_per_page' => -1,
349 349
             'year'           => $year,
350 350
             'fields'         => 'ids'
351 351
         );
352 352
 
353
-        $payments    = get_posts( $args );
354
-        $payment_ids = implode( ',', $payments );
353
+        $payments    = get_posts($args);
354
+        $payment_ids = implode(',', $payments);
355 355
 
356
-        if ( count( $payments ) > 0 ) {
356
+        if (count($payments) > 0) {
357 357
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
358
-            $tax = $wpdb->get_var( $sql );
358
+            $tax = $wpdb->get_var($sql);
359 359
         }
360 360
 
361 361
     }
362 362
 
363
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
363
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
364 364
 }
365 365
 
366 366
 function wpinv_is_cart_taxed() {
@@ -369,33 +369,33 @@  discard block
 block discarded – undo
369 369
 
370 370
 function wpinv_prices_show_tax_on_checkout() {
371 371
     return false; // TODO
372
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
372
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
373 373
 
374
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
374
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
375 375
 }
376 376
 
377 377
 function wpinv_display_tax_rate() {
378
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
378
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
379 379
 
380
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
380
+    return apply_filters('wpinv_display_tax_rate', $ret);
381 381
 }
382 382
 
383 383
 function wpinv_cart_needs_tax_address_fields() {
384
-    if( !wpinv_is_cart_taxed() )
384
+    if (!wpinv_is_cart_taxed())
385 385
         return false;
386 386
 
387
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
387
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
388 388
 }
389 389
 
390
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
391
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
392
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
390
+function wpinv_item_is_tax_exclusive($item_id = 0) {
391
+    $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false);
392
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
393 393
 }
394 394
 
395
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
395
+function wpinv_currency_decimal_filter($decimals = 2) {
396 396
     $currency = wpinv_get_currency();
397 397
 
398
-    switch ( $currency ) {
398
+    switch ($currency) {
399 399
         case 'RIAL' :
400 400
         case 'JPY' :
401 401
         case 'TWD' :
@@ -404,50 +404,50 @@  discard block
 block discarded – undo
404 404
             break;
405 405
     }
406 406
 
407
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
407
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
408 408
 }
409 409
 
410 410
 function wpinv_tax_amount() {
411 411
     $output = 0.00;
412 412
     
413
-    return apply_filters( 'wpinv_tax_amount', $output );
413
+    return apply_filters('wpinv_tax_amount', $output);
414 414
 }
415 415
 
416 416
 // VAT Settings
417
-function wpinv_vat_rate_add_callback( $args ) {
417
+function wpinv_vat_rate_add_callback($args) {
418 418
     ?>
419
-    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e( 'Add', 'invoicing' );?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
419
+    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
420 420
     <?php
421 421
 }
422 422
 
423
-function wpinv_vat_rate_delete_callback( $args ) {
423
+function wpinv_vat_rate_delete_callback($args) {
424 424
     global $wpinv_euvat;
425 425
     
426 426
     $vat_classes = $wpinv_euvat->get_rate_classes();
427
-    $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '';
428
-    if ( isset( $vat_classes[$vat_class] ) ) {
427
+    $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '';
428
+    if (isset($vat_classes[$vat_class])) {
429 429
     ?>
430
-    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf( esc_attr__( 'Delete class "%s"', 'invoicing' ), $vat_classes[$vat_class] );?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
430
+    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf(esc_attr__('Delete class "%s"', 'invoicing'), $vat_classes[$vat_class]); ?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
431 431
     <?php
432 432
     }
433 433
 }
434 434
 
435
-function wpinv_vat_rates_callback( $args ) {
435
+function wpinv_vat_rates_callback($args) {
436 436
     global $wpinv_euvat;
437 437
     
438 438
     $vat_classes    = $wpinv_euvat->get_rate_classes();
439
-    $vat_class      = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_standard';
439
+    $vat_class      = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_standard';
440 440
     
441 441
     $eu_states      = $wpinv_euvat->get_eu_states();
442 442
     $countries      = wpinv_get_country_list();
443 443
     $vat_groups     = $wpinv_euvat->get_vat_groups();
444
-    $rates          = $wpinv_euvat->get_vat_rates( $vat_class );
444
+    $rates          = $wpinv_euvat->get_vat_rates($vat_class);
445 445
     ob_start();
446 446
 ?>
447 447
 </td><tr>
448 448
     <td colspan="2" class="wpinv_vat_tdbox">
449
-    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class;?>" />
450
-    <p><?php echo ( isset( $args['desc'] ) ? $args['desc'] : '' ); ?></p>
449
+    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class; ?>" />
450
+    <p><?php echo (isset($args['desc']) ? $args['desc'] : ''); ?></p>
451 451
     <table id="wpinv_vat_rates" class="wp-list-table widefat fixed posts">
452 452
         <colgroup>
453 453
             <col width="50px" />
@@ -459,43 +459,43 @@  discard block
 block discarded – undo
459 459
         </colgroup>
460 460
         <thead>
461 461
             <tr>
462
-                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e( 'Country', 'invoicing' ); ?></th>
463
-                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e( 'Apply rate to whole country', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
464
-                <th scope="col" class="wpinv_vat_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
465
-                <th scope="col" class="wpinv_vat_name"><?php _e( 'VAT Name', 'invoicing' ); ?></th>
466
-                <th scope="col" class="wpinv_vat_group"><?php _e( 'Tax Group', 'invoicing' ); ?></th>
462
+                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e('Country', 'invoicing'); ?></th>
463
+                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e('Apply rate to whole country', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
464
+                <th scope="col" class="wpinv_vat_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
465
+                <th scope="col" class="wpinv_vat_name"><?php _e('VAT Name', 'invoicing'); ?></th>
466
+                <th scope="col" class="wpinv_vat_group"><?php _e('Tax Group', 'invoicing'); ?></th>
467 467
             </tr>
468 468
         </thead>
469 469
         <tbody>
470
-        <?php if( !empty( $eu_states ) ) { ?>
470
+        <?php if (!empty($eu_states)) { ?>
471 471
         <?php 
472
-        foreach ( $eu_states as $state ) { 
473
-            $country_name = isset( $countries[$state] ) ? $countries[$state] : '';
472
+        foreach ($eu_states as $state) { 
473
+            $country_name = isset($countries[$state]) ? $countries[$state] : '';
474 474
             
475 475
             // Filter the rate for each country
476
-            $country_rate = array_filter( $rates, function( $rate ) use( $state ) { return $rate['country'] === $state; } );
476
+            $country_rate = array_filter($rates, function($rate) use($state) { return $rate['country'] === $state; } );
477 477
             
478 478
             // If one does not exist create a default
479
-            $country_rate = is_array( $country_rate ) && count( $country_rate ) > 0 ? reset( $country_rate ) : array();
479
+            $country_rate = is_array($country_rate) && count($country_rate) > 0 ? reset($country_rate) : array();
480 480
             
481
-            $vat_global = isset( $country_rate['global'] ) ? !empty( $country_rate['global'] ) : true;
482
-            $vat_rate = isset( $country_rate['rate'] ) ? $country_rate['rate'] : '';
483
-            $vat_name = !empty( $country_rate['name'] ) ? esc_attr( stripslashes( $country_rate['name'] ) ) : '';
484
-            $vat_group = !empty( $country_rate['group'] ) ? $country_rate['group'] : ( $vat_class === '_standard' ? 'standard' : 'reduced' );
481
+            $vat_global = isset($country_rate['global']) ? !empty($country_rate['global']) : true;
482
+            $vat_rate = isset($country_rate['rate']) ? $country_rate['rate'] : '';
483
+            $vat_name = !empty($country_rate['name']) ? esc_attr(stripslashes($country_rate['name'])) : '';
484
+            $vat_group = !empty($country_rate['group']) ? $country_rate['group'] : ($vat_class === '_standard' ? 'standard' : 'reduced');
485 485
         ?>
486 486
         <tr>
487 487
             <td class="wpinv_vat_country"><?php echo $state; ?><input type="hidden" name="vat_rates[<?php echo $state; ?>][country]" value="<?php echo $state; ?>" /><input type="hidden" name="vat_rates[<?php echo $state; ?>][state]" value="" /></td>
488 488
             <td class="wpinv_vat_country_name"><?php echo $country_name; ?></td>
489 489
             <td class="wpinv_vat_global">
490
-                <input type="checkbox" name="vat_rates[<?php echo $state;?>][global]" id="vat_rates[<?php echo $state;?>][global]" value="1" <?php checked( true, $vat_global );?> disabled="disabled" />
491
-                <label for="tax_rates[<?php echo $state;?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
492
-                <input type="hidden" name="vat_rates[<?php echo $state;?>][global]" value="1" checked="checked" />
490
+                <input type="checkbox" name="vat_rates[<?php echo $state; ?>][global]" id="vat_rates[<?php echo $state; ?>][global]" value="1" <?php checked(true, $vat_global); ?> disabled="disabled" />
491
+                <label for="tax_rates[<?php echo $state; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
492
+                <input type="hidden" name="vat_rates[<?php echo $state; ?>][global]" value="1" checked="checked" />
493 493
             </td>
494
-            <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state;?>][rate]" value="<?php echo $vat_rate; ?>" /></td>
495
-            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state;?>][name]" value="<?php echo $vat_name; ?>" /></td>
494
+            <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state; ?>][rate]" value="<?php echo $vat_rate; ?>" /></td>
495
+            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state; ?>][name]" value="<?php echo $vat_name; ?>" /></td>
496 496
             <td class="wpinv_vat_group">
497 497
             <?php
498
-            echo wpinv_html_select( array(
498
+            echo wpinv_html_select(array(
499 499
                                         'name'             => 'vat_rates[' . $state . '][group]',
500 500
                                         'selected'         => $vat_group,
501 501
                                         'id'               => 'vat_rates[' . $state . '][group]',
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
                                         'multiple'         => false,
505 505
                                         'show_option_all'  => false,
506 506
                                         'show_option_none' => false
507
-                                    ) );
507
+                                    ));
508 508
             ?>
509 509
             </td>
510 510
         </tr>
511 511
         <?php } ?>
512 512
         <tr>
513 513
             <td colspan="6" style="background-color:#fafafa;">
514
-                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e( 'Update EU VAT Rates', 'invoicing' ); ?>" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span>
514
+                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e('Update EU VAT Rates', 'invoicing'); ?>" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span>
515 515
             </td>
516 516
         </tr>
517 517
         <?php } ?>
@@ -528,25 +528,25 @@  discard block
 block discarded – undo
528 528
  * 
529 529
  * @param string|bool|null $vat_rule
530 530
  */
531
-function getpaid_filter_vat_rule( $vat_rule ) {
531
+function getpaid_filter_vat_rule($vat_rule) {
532 532
 
533
-    if ( empty( $vat_rule ) ) {        
533
+    if (empty($vat_rule)) {        
534 534
         return 'digital';
535 535
     }
536 536
 
537 537
     return $vat_rule;
538 538
 }
539
-add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' );
539
+add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule');
540 540
 
541 541
 /**
542 542
  * Filters the VAT class to ensure that each item has a VAT class.
543 543
  * 
544 544
  * @param string|bool|null $vat_rule
545 545
  */
546
-function getpaid_filter_vat_class( $vat_class ) {
547
-    return empty( $vat_class ) ? '_standard' : $vat_class;
546
+function getpaid_filter_vat_class($vat_class) {
547
+    return empty($vat_class) ? '_standard' : $vat_class;
548 548
 }
549
-add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' );
549
+add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class');
550 550
 
551 551
 /**
552 552
  * Returns a list of all tax classes.
@@ -558,9 +558,9 @@  discard block
 block discarded – undo
558 558
     return apply_filters(
559 559
         'getpaid_tax_classes',
560 560
         array(
561
-            '_standard' => __( 'Standard Tax Rate', 'invoicing' ),
562
-            '_reduced'  => __( 'Reduced Tax Rate', 'invoicing' ),
563
-            '_exempt'   => __( 'Tax Exempt', 'invoicing' ),
561
+            '_standard' => __('Standard Tax Rate', 'invoicing'),
562
+            '_reduced'  => __('Reduced Tax Rate', 'invoicing'),
563
+            '_exempt'   => __('Tax Exempt', 'invoicing'),
564 564
         )
565 565
     );
566 566
 
@@ -576,8 +576,8 @@  discard block
 block discarded – undo
576 576
     return apply_filters(
577 577
         'getpaid_tax_rules',
578 578
         array(
579
-            'physical' => __( 'Physical Item', 'invoicing' ),
580
-            'digital'  => __( 'Digital Item', 'invoicing' ),
579
+            'physical' => __('Physical Item', 'invoicing'),
580
+            'digital'  => __('Digital Item', 'invoicing'),
581 581
         )
582 582
     );
583 583
 
@@ -589,15 +589,15 @@  discard block
 block discarded – undo
589 589
  * @param string $tax_class
590 590
  * @return string
591 591
  */
592
-function getpaid_get_tax_class_label( $tax_class ) {
592
+function getpaid_get_tax_class_label($tax_class) {
593 593
 
594 594
     $classes = getpaid_get_tax_classes();
595 595
 
596
-    if ( isset( $classes[ $tax_class ] ) ) {
597
-        return sanitize_text_field( $classes[ $tax_class ] );
596
+    if (isset($classes[$tax_class])) {
597
+        return sanitize_text_field($classes[$tax_class]);
598 598
     }
599 599
 
600
-    return sanitize_text_field( $tax_class );
600
+    return sanitize_text_field($tax_class);
601 601
 
602 602
 }
603 603
 
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
  * @param string $tax_rule
608 608
  * @return string
609 609
  */
610
-function getpaid_get_tax_rule_label( $tax_rule ) {
610
+function getpaid_get_tax_rule_label($tax_rule) {
611 611
 
612 612
     $rules = getpaid_get_tax_rules();
613 613
 
614
-    if ( isset( $rules[ $tax_rule ] ) ) {
615
-        return sanitize_text_field( $rules[ $tax_rule ] );
614
+    if (isset($rules[$tax_rule])) {
615
+        return sanitize_text_field($rules[$tax_rule]);
616 616
     }
617 617
 
618
-    return sanitize_text_field( $tax_rule );
618
+    return sanitize_text_field($tax_rule);
619 619
 
620 620
 }
Please login to merge, or discard this patch.
templates/invoice/company-address.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Prepare the company name.
13
-$company_name = wpinv_get_option( 'vat_company_name' );
13
+$company_name = wpinv_get_option('vat_company_name');
14 14
 
15
-if ( empty( $company_name ) ) {
15
+if (empty($company_name)) {
16 16
     $company_name = wpinv_get_business_name();
17 17
 }
18 18
 
@@ -22,30 +22,30 @@  discard block
 block discarded – undo
22 22
         <div class="row">
23 23
 
24 24
             <div class="invoice-company-address-label col-2">
25
-                <strong><?php _e( 'From:', 'invoicing' ) ?></strong>
25
+                <strong><?php _e('From:', 'invoicing') ?></strong>
26 26
             </div>
27 27
 
28 28
             <div class="invoice-company-address-value col-10">
29 29
 
30
-                <?php do_action( 'getpaid_company_address_top' ); ?>
30
+                <?php do_action('getpaid_company_address_top'); ?>
31 31
 
32 32
                 <div class="name">
33
-                    <a target="_blank" class="text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
34
-                        <?php echo esc_html( wpinv_get_business_name() ); ?>
33
+                    <a target="_blank" class="text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
34
+                        <?php echo esc_html(wpinv_get_business_name()); ?>
35 35
                     </a>
36 36
                 </div>
37 37
 
38
-                <?php if ( $address = wpinv_get_business_address() ) { ?>
39
-                    <?php echo $address;?>
38
+                <?php if ($address = wpinv_get_business_address()) { ?>
39
+                    <?php echo $address; ?>
40 40
                 <?php } ?>
41 41
 
42
-                <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
42
+                <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
43 43
                     <div class="email_from">
44
-                        <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?>
44
+                        <?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?>
45 45
                     </div>
46 46
                 <?php } ?>
47 47
 
48
-                <?php do_action( 'getpaid_company_address_bottom' ); ?>
48
+                <?php do_action('getpaid_company_address_bottom'); ?>
49 49
 
50 50
             </div>
51 51
 
Please login to merge, or discard this patch.