Passed
Push — master ( 219dea...32accd )
by Brian
05:24
created
includes/admin/class-wpinv-customers-table.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 exit;
10 10
 }
11 11
 
12 12
 // Load WP_List_Table if not loaded
13
-if ( ! class_exists( 'WP_List_Table' ) ) {
13
+if (!class_exists('WP_List_Table')) {
14 14
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
15 15
 }
16 16
 
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return string Column Name
78 78
 	 */
79
-	public function column_default( $item, $column_name ) {
80
-		$value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
81
-		return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
79
+	public function column_default($item, $column_name) {
80
+		$value = esc_html(get_user_meta($item->ID, '_wpinv_' . $column_name, true));
81
+		return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item);
82 82
 	}
83 83
 
84 84
 	/**
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return string Column Name
92 92
 	 */
93
-	public function column_country( $user ) {
94
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
95
-		if ( $country ) {
96
-			$country = wpinv_country_name( $country );
93
+	public function column_country($user) {
94
+		$country = wpinv_sanitize_country($user->_wpinv_country);
95
+		if ($country) {
96
+			$country = wpinv_country_name($country);
97 97
 		}
98
-		return esc_html( $country );
98
+		return esc_html($country);
99 99
 	}
100 100
 
101 101
 	/**
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return string Column Name
109 109
 	 */
110
-	public function column_state( $user ) {
111
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
110
+	public function column_state($user) {
111
+		$country = wpinv_sanitize_country($user->_wpinv_country);
112 112
 		$state   = $user->_wpinv_state;
113
-		if ( $state ) {
114
-			$state = wpinv_state_name( $state, $country );
113
+		if ($state) {
114
+			$state = wpinv_state_name($state, $country);
115 115
 		}
116 116
 
117
-		return esc_html( $state );
117
+		return esc_html($state);
118 118
 	}
119 119
 
120 120
 	/**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return string Column Name
128 128
 	 */
129
-	public function column_signup( $user ) {
130
-		return getpaid_format_date_value( $user->user_registered );
129
+	public function column_signup($user) {
130
+		return getpaid_format_date_value($user->user_registered);
131 131
 	}
132 132
 
133 133
 	/**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 *
140 140
 	 * @return string Column Name
141 141
 	 */
142
-	public function column_total( $user ) {
143
-		return wpinv_price( $this->column_total_raw( $user ) );
142
+	public function column_total($user) {
143
+		return wpinv_price($this->column_total_raw($user));
144 144
 	}
145 145
 
146 146
 	/**
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return float
154 154
 	 */
155
-	public function column_total_raw( $user ) {
155
+	public function column_total_raw($user) {
156 156
 
157 157
 		$args = array(
158 158
 			'data'           => array(
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
 
169 169
 				'author' => array(
170 170
 					'type'     => 'post_data',
171
-					'value'    => absint( $user->ID ),
171
+					'value'    => absint($user->ID),
172 172
 					'key'      => 'posts.post_author',
173 173
 					'operator' => '=',
174 174
 				),
175 175
 
176 176
 			),
177 177
 			'query_type'     => 'get_var',
178
-			'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
178
+			'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'),
179 179
 		);
180 180
 
181
-		return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
181
+		return wpinv_round_amount(GetPaid_Reports_Helper::get_invoice_report_data($args));
182 182
 
183 183
 	}
184 184
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @return string Column Name
193 193
 	 */
194
-	public function column_invoices( $user ) {
194
+	public function column_invoices($user) {
195 195
 
196 196
 		$args = array(
197 197
 			'data'           => array(
@@ -208,19 +208,19 @@  discard block
 block discarded – undo
208 208
 
209 209
 				'author' => array(
210 210
 					'type'     => 'post_data',
211
-					'value'    => absint( $user->ID ),
211
+					'value'    => absint($user->ID),
212 212
 					'key'      => 'posts.post_author',
213 213
 					'operator' => '=',
214 214
 				),
215 215
 
216 216
 			),
217 217
 			'query_type'     => 'get_var',
218
-			'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
218
+			'invoice_status' => array_keys(wpinv_get_invoice_statuses()),
219 219
 		);
220 220
 
221
-		$value = absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
222
-		$url   = add_query_arg( array( 'post_type' => 'wpi_invoice', 'author' => $user->ID ), admin_url( 'edit.php' ) );
223
-		return empty( $value ) ? '0' : '<a href="' . esc_url( $url ) . '">' . absint( $value ) . '</a>';
221
+		$value = absint(GetPaid_Reports_Helper::get_invoice_report_data($args));
222
+		$url   = add_query_arg(array('post_type' => 'wpi_invoice', 'author' => $user->ID), admin_url('edit.php'));
223
+		return empty($value) ? '0' : '<a href="' . esc_url($url) . '">' . absint($value) . '</a>';
224 224
 
225 225
 	}
226 226
 
@@ -230,15 +230,15 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @param int $item The user id.
232 232
 	 */
233
-	public function single_row( $item ) {
234
-		$item = get_user_by( 'id', $item );
233
+	public function single_row($item) {
234
+		$item = get_user_by('id', $item);
235 235
 
236
-		if ( empty( $item ) ) {
236
+		if (empty($item)) {
237 237
 			return;
238 238
 		}
239 239
 
240 240
 		echo '<tr>';
241
-		$this->single_row_columns( $item );
241
+		$this->single_row_columns($item);
242 242
 		echo '</tr>';
243 243
 	}
244 244
 
@@ -248,34 +248,34 @@  discard block
 block discarded – undo
248 248
 	 * @param  WP_User $customer customer.
249 249
 	 * @return string
250 250
 	 */
251
-	public function column_name( $customer ) {
251
+	public function column_name($customer) {
252 252
 
253 253
 		// Customer view URL.
254
-		$view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
254
+		$view_url    = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php')));
255 255
 		$row_actions = $this->row_actions(
256 256
 			array(
257
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
257
+				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>',
258 258
 			)
259 259
 		);
260 260
 
261 261
 		// Get user's address.
262
-		$address = wpinv_get_user_address( $customer->ID );
262
+		$address = wpinv_get_user_address($customer->ID);
263 263
 
264 264
 		// Customer email address.
265
-		$email       = sanitize_email( $customer->user_email );
265
+		$email = sanitize_email($customer->user_email);
266 266
 
267 267
 		// Customer's avatar.
268
-		$avatar = esc_url( get_avatar_url( $email ) );
268
+		$avatar = esc_url(get_avatar_url($email));
269 269
 		$avatar = "<img src='$avatar' height='32' width='32'/>";
270 270
 
271 271
 		// Customer's name.
272
-		$name   = esc_html( "{$address['first_name']} {$address['last_name']}" );
272
+		$name   = esc_html("{$address['first_name']} {$address['last_name']}");
273 273
 
274
-		if ( empty( trim( $name ) ) ) {
275
-			$name = esc_html( $address['display_name'] );
274
+		if (empty(trim($name))) {
275
+			$name = esc_html($address['display_name']);
276 276
 		}
277 277
 
278
-		if ( ! empty( $name ) ) {
278
+		if (!empty($name)) {
279 279
 			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
280 280
 		}
281 281
 
@@ -294,19 +294,19 @@  discard block
 block discarded – undo
294 294
 	public function get_columns() {
295 295
 
296 296
 		$columns = array(
297
-			'name'     => __( 'Name', 'invoicing' ),
298
-			'country'  => __( 'Country', 'invoicing' ),
299
-			'state'    => __( 'State', 'invoicing' ),
300
-			'city'     => __( 'City', 'invoicing' ),
301
-			'zip'      => __( 'ZIP', 'invoicing' ),
302
-			'address'  => __( 'Address', 'invoicing' ),
303
-			'phone'    => __( 'Phone', 'invoicing' ),
304
-			'company'  => __( 'Company', 'invoicing' ),
305
-			'invoices' => __( 'Invoices', 'invoicing' ),
306
-			'total'    => __( 'Total Spend', 'invoicing' ),
307
-			'signup'   => __( 'Date created', 'invoicing' ),
297
+			'name'     => __('Name', 'invoicing'),
298
+			'country'  => __('Country', 'invoicing'),
299
+			'state'    => __('State', 'invoicing'),
300
+			'city'     => __('City', 'invoicing'),
301
+			'zip'      => __('ZIP', 'invoicing'),
302
+			'address'  => __('Address', 'invoicing'),
303
+			'phone'    => __('Phone', 'invoicing'),
304
+			'company'  => __('Company', 'invoicing'),
305
+			'invoices' => __('Invoices', 'invoicing'),
306
+			'total'    => __('Total Spend', 'invoicing'),
307
+			'signup'   => __('Date created', 'invoicing'),
308 308
 		);
309
-		return apply_filters( 'wpinv_customers_table_columns', $columns );
309
+		return apply_filters('wpinv_customers_table_columns', $columns);
310 310
 
311 311
 	}
312 312
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 * @return int Current page number
318 318
 	 */
319 319
 	public function get_paged() {
320
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
320
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
321 321
 	}
322 322
 
323 323
 	/**
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 * @since 1.0.19
327 327
 	 * @return void
328 328
 	 */
329
-	public function bulk_actions( $which = '' ) {
329
+	public function bulk_actions($which = '') {
330 330
 		return array();
331 331
 	}
332 332
 
@@ -338,23 +338,23 @@  discard block
 block discarded – undo
338 338
 
339 339
 		$post_types = '';
340 340
 
341
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
342
-			$post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
341
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
342
+			$post_types .= $wpdb->prepare('post_type=%s OR ', $post_type);
343 343
 		}
344 344
 
345
-		$post_types = rtrim( $post_types, ' OR' );
345
+		$post_types = rtrim($post_types, ' OR');
346 346
 
347 347
 		// Maybe search.
348
-		if ( ! empty( $_POST['s'] ) ) {
348
+		if (!empty($_POST['s'])) {
349 349
 			$users = get_users(
350 350
 				array(
351
-					'search'         => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*',
352
-					'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
351
+					'search'         => '*' . sanitize_text_field(urldecode($_POST['s'])) . '*',
352
+					'search_columns' => array('user_login', 'user_email', 'display_name'),
353 353
 					'fields'         => 'ID',
354 354
 				)
355 355
 			);
356 356
 
357
-			$users      = implode( ', ', $users );
357
+			$users      = implode(', ', $users);
358 358
 			$post_types = "($post_types) AND ( post_author IN ( $users ) )";
359 359
 		}
360 360
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 		);
369 369
 
370 370
 		$this->items = $customers;
371
-		$this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" );
371
+		$this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types");
372 372
 
373 373
 	}
374 374
 
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
 		$columns               = $this->get_columns();
383 383
 		$hidden                = array(); // No hidden columns
384 384
 		$sortable              = $this->get_sortable_columns();
385
-		$this->_column_headers = array( $columns, $hidden, $sortable );
385
+		$this->_column_headers = array($columns, $hidden, $sortable);
386 386
 		$this->prepare_query();
387 387
 
388 388
 		$this->set_pagination_args(
389 389
 			array(
390 390
 				'total_items' => $this->total,
391 391
 				'per_page'    => $this->per_page,
392
-				'total_pages' => ceil( $this->total / $this->per_page ),
392
+				'total_pages' => ceil($this->total / $this->per_page),
393 393
 			)
394 394
 		);
395 395
 
Please login to merge, or discard this patch.