Passed
Push — master ( 2aa340...5b03f5 )
by Brian
05:43 queued 46s
created
includes/admin/class-wpinv-customers-table.php 2 patches
Indentation   +337 added lines, -337 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,340 +21,340 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Customers_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 10;
29
-
30
-	/**
31
-	 * @var int Number of items
32
-	 * @since 1.0.19
33
-	 */
34
-	public $total = 0;
35
-
36
-	/**
37
-	 * Get things started
38
-	 *
39
-	 * @since 1.0.19
40
-	 * @see WP_List_Table::__construct()
41
-	 */
42
-	public function __construct() {
43
-
44
-		// Set parent defaults
45
-		parent::__construct( array(
46
-			'singular' => 'id',
47
-			'plural'   => 'ids',
48
-			'ajax'     => false,
49
-		) );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Gets the name of the primary column.
55
-	 *
56
-	 * @since 1.0.19
57
-	 * @access protected
58
-	 *
59
-	 * @return string Name of the primary column.
60
-	 */
61
-	protected function get_primary_column_name() {
62
-		return 'name';
63
-	}
64
-
65
-	/**
66
-	 * This function renders most of the columns in the list table.
67
-	 *
68
-	 * @since 1.0.19
69
-	 *
70
-	 * @param WP_User $item
71
-	 * @param string $column_name The name of the column
72
-	 *
73
-	 * @return string Column Name
74
-	 */
75
-	public function column_default( $item, $column_name ) {
76
-		$value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
77
-		return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
78
-	}
79
-
80
-	/**
81
-	 * Displays the country column.
82
-	 *
83
-	 * @since 1.0.19
84
-	 *
85
-	 * @param WP_User $user
86
-	 *
87
-	 * @return string Column Name
88
-	 */
89
-	public function column_country( $user ) {
90
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
91
-		if ( $country ) {
92
-			$country = wpinv_country_name( $country );
93
-		}
94
-		return sanitize_text_field( $country );
95
-	}
96
-
97
-	/**
98
-	 * Displays the state column.
99
-	 *
100
-	 * @since 1.0.19
101
-	 *
102
-	 * @param WP_User $user
103
-	 *
104
-	 * @return string Column Name
105
-	 */
106
-	public function column_state( $user ) {
107
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
108
-		$state   = $user->_wpinv_state;
109
-		if ( $state ) {
110
-			$state = wpinv_state_name( $state, $country );
111
-		}
112
-
113
-		return sanitize_text_field( $state );
114
-	}
115
-
116
-	/**
117
-	 * Displays the signup column.
118
-	 *
119
-	 * @since 1.0.19
120
-	 *
121
-	 * @param WP_User $user
122
-	 *
123
-	 * @return string Column Name
124
-	 */
125
-	public function column_signup( $user ) {
126
-		return getpaid_format_date_value( $user->user_registered );
127
-	}
128
-
129
-	/**
130
-	 * Displays the total spent column.
131
-	 *
132
-	 * @since 1.0.19
133
-	 *
134
-	 * @param WP_User $user
135
-	 *
136
-	 * @return string Column Name
137
-	 */
138
-	public function column_total( $user ) {
139
-
140
-		$args = array(
141
-			'data'             => array(
142
-
143
-				'total'        => array(
144
-					'type'     => 'invoice_data',
145
-					'function' => 'SUM',
146
-					'name'     => 'total_sales',
147
-				)
148
-
149
-			),
150
-			'where'            => array(
151
-
152
-				'author'       => array(
153
-					'type'     => 'post_data',
154
-					'value'    => absint( $user->ID ),
155
-					'key'      => 'posts.post_author',
156
-					'operator' => '=',
157
-				),
158
-
159
-			),
160
-			'query_type'     => 'get_var',
161
-			'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
162
-		);
163
-
164
-		return wpinv_price( (float) GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
165
-
166
-	}
167
-
168
-	/**
169
-	 * Displays the total spent column.
170
-	 *
171
-	 * @since 1.0.19
172
-	 *
173
-	 * @param WP_User $user
174
-	 *
175
-	 * @return string Column Name
176
-	 */
177
-	public function column_invoices( $user ) {
178
-
179
-		$args = array(
180
-			'data'             => array(
181
-
182
-				'ID'           => array(
183
-					'type'     => 'post_data',
184
-					'function' => 'COUNT',
185
-					'name'     => 'count',
186
-					'distinct' => true,
187
-				),
188
-
189
-			),
190
-			'where'            => array(
191
-
192
-				'author'       => array(
193
-					'type'     => 'post_data',
194
-					'value'    => absint( $user->ID ),
195
-					'key'      => 'posts.post_author',
196
-					'operator' => '=',
197
-				),
198
-
199
-			),
200
-			'query_type'     => 'get_var',
201
-			'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
202
-		);
203
-
204
-		return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
205
-
206
-	}
207
-
208
-	/**
209
-	 * Generates content for a single row of the table
210
-	 * @since 1.0.19
211
-	 *
212
-	 * @param int $item The user id.
213
-	 */
214
-	public function single_row( $item ) {
215
-		$item = get_user_by( 'id', $item );
216
-
217
-		if ( empty( $item ) ) {
218
-			return;
219
-		}
220
-
221
-		echo '<tr>';
222
-		$this->single_row_columns( $item );
223
-		echo '</tr>';
224
-	}
225
-
226
-	/**
227
-	 * Displays the customers name
228
-	 *
229
-	 * @param  WP_User $customer customer.
230
-	 * @return string
231
-	 */
232
-	public function column_name( $customer ) {
233
-
234
-		// Customer view URL.
235
-		$view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
236
-		$row_actions = $this->row_actions(
237
-			array(
238
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
239
-			)
240
-		);
241
-
242
-		// Get user's address.
243
-		$address = wpinv_get_user_address( $customer->ID );
244
-
245
-		// Customer email address.
246
-		$email       = sanitize_email( $customer->user_email );
247
-
248
-		// Customer's avatar.
249
-		$avatar = esc_url( get_avatar_url( $email ) );
250
-		$avatar = "<img src='$avatar' height='32' width='32'/>";
251
-
252
-		// Customer's name.
253
-		$name   = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" );
254
-
255
-		if ( ! empty( $name ) ) {
256
-			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
257
-		}
258
-
259
-		$email = "<div class='row-title'><a href='$view_url'>$email</a></div>";
260
-
261
-		return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>";
262
-
263
-	}
264
-
265
-	/**
266
-	 * Retrieve the table columns
267
-	 *
268
-	 * @since 1.0.19
269
-	 * @return array $columns Array of all the list table columns
270
-	 */
271
-	public function get_columns() {
272
-
273
-		$columns = array(
274
-			'name'     => __( 'Name', 'invoicing' ),
275
-			'country'  => __( 'Country', 'invoicing' ),
276
-			'state'    => __( 'State', 'invoicing' ),
277
-			'city'     => __( 'City', 'invoicing' ),
278
-			'zip'      => __( 'ZIP', 'invoicing' ),
279
-			'address'  => __( 'Address', 'invoicing' ),
280
-			'phone'    => __( 'Phone', 'invoicing' ),
281
-			'company'  => __( 'Company', 'invoicing' ),
282
-			'invoices' => __( 'Invoices', 'invoicing' ),
283
-			'total'    => __( 'Total Spend', 'invoicing' ),
284
-			'signup'   => __( 'Date created', 'invoicing' ),
285
-		);
286
-		return apply_filters( 'wpinv_customers_table_columns', $columns );
287
-
288
-	}
289
-
290
-	/**
291
-	 * Retrieve the current page number
292
-	 *
293
-	 * @since 1.0.19
294
-	 * @return int Current page number
295
-	 */
296
-	public function get_paged() {
297
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
298
-	}
299
-
300
-	/**
301
-	 * Returns bulk actions.
302
-	 *
303
-	 * @since 1.0.19
304
-	 * @return void
305
-	 */
306
-	public function bulk_actions( $which = '' ) {
307
-		return array();
308
-	}
309
-
310
-	/**
311
-	 *  Prepares the display query
312
-	 */
313
-	public function prepare_query() {
314
-		global $wpdb;
315
-
316
-		$post_types = 'WHERE ';
317
-
318
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
319
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
320
-		}
321
-
322
-		$post_types = rtrim( $post_types, ' OR' );
323
-
324
-		// Users with invoices.
325
-    	$customers = $wpdb->get_col(
326
-			$wpdb->prepare(
327
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts $post_types LIMIT %d,%d",
328
-				$this->get_paged() * 10 - 10,
329
-				$this->per_page
330
-			)
331
-		);
332
-
333
-		$this->items = $customers;
334
-		$this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types" );
335
-
336
-	}
337
-
338
-	/**
339
-	 * Setup the final data for the table
340
-	 *
341
-	 * @since 1.0.19
342
-	 * @return void
343
-	 */
344
-	public function prepare_items() {
345
-		$columns               = $this->get_columns();
346
-		$hidden                = array(); // No hidden columns
347
-		$sortable              = $this->get_sortable_columns();
348
-		$this->_column_headers = array( $columns, $hidden, $sortable );
349
-		$this->prepare_query();
350
-
351
-		$this->set_pagination_args(
352
-			array(
353
-			'total_items' => $this->total,
354
-			'per_page'    => $this->per_page,
355
-			'total_pages' => ceil( $this->total / $this->per_page )
356
-			)
357
-		);
358
-
359
-	}
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 10;
29
+
30
+    /**
31
+     * @var int Number of items
32
+     * @since 1.0.19
33
+     */
34
+    public $total = 0;
35
+
36
+    /**
37
+     * Get things started
38
+     *
39
+     * @since 1.0.19
40
+     * @see WP_List_Table::__construct()
41
+     */
42
+    public function __construct() {
43
+
44
+        // Set parent defaults
45
+        parent::__construct( array(
46
+            'singular' => 'id',
47
+            'plural'   => 'ids',
48
+            'ajax'     => false,
49
+        ) );
50
+
51
+    }
52
+
53
+    /**
54
+     * Gets the name of the primary column.
55
+     *
56
+     * @since 1.0.19
57
+     * @access protected
58
+     *
59
+     * @return string Name of the primary column.
60
+     */
61
+    protected function get_primary_column_name() {
62
+        return 'name';
63
+    }
64
+
65
+    /**
66
+     * This function renders most of the columns in the list table.
67
+     *
68
+     * @since 1.0.19
69
+     *
70
+     * @param WP_User $item
71
+     * @param string $column_name The name of the column
72
+     *
73
+     * @return string Column Name
74
+     */
75
+    public function column_default( $item, $column_name ) {
76
+        $value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
77
+        return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
78
+    }
79
+
80
+    /**
81
+     * Displays the country column.
82
+     *
83
+     * @since 1.0.19
84
+     *
85
+     * @param WP_User $user
86
+     *
87
+     * @return string Column Name
88
+     */
89
+    public function column_country( $user ) {
90
+        $country = wpinv_sanitize_country( $user->_wpinv_country );
91
+        if ( $country ) {
92
+            $country = wpinv_country_name( $country );
93
+        }
94
+        return sanitize_text_field( $country );
95
+    }
96
+
97
+    /**
98
+     * Displays the state column.
99
+     *
100
+     * @since 1.0.19
101
+     *
102
+     * @param WP_User $user
103
+     *
104
+     * @return string Column Name
105
+     */
106
+    public function column_state( $user ) {
107
+        $country = wpinv_sanitize_country( $user->_wpinv_country );
108
+        $state   = $user->_wpinv_state;
109
+        if ( $state ) {
110
+            $state = wpinv_state_name( $state, $country );
111
+        }
112
+
113
+        return sanitize_text_field( $state );
114
+    }
115
+
116
+    /**
117
+     * Displays the signup column.
118
+     *
119
+     * @since 1.0.19
120
+     *
121
+     * @param WP_User $user
122
+     *
123
+     * @return string Column Name
124
+     */
125
+    public function column_signup( $user ) {
126
+        return getpaid_format_date_value( $user->user_registered );
127
+    }
128
+
129
+    /**
130
+     * Displays the total spent column.
131
+     *
132
+     * @since 1.0.19
133
+     *
134
+     * @param WP_User $user
135
+     *
136
+     * @return string Column Name
137
+     */
138
+    public function column_total( $user ) {
139
+
140
+        $args = array(
141
+            'data'             => array(
142
+
143
+                'total'        => array(
144
+                    'type'     => 'invoice_data',
145
+                    'function' => 'SUM',
146
+                    'name'     => 'total_sales',
147
+                )
148
+
149
+            ),
150
+            'where'            => array(
151
+
152
+                'author'       => array(
153
+                    'type'     => 'post_data',
154
+                    'value'    => absint( $user->ID ),
155
+                    'key'      => 'posts.post_author',
156
+                    'operator' => '=',
157
+                ),
158
+
159
+            ),
160
+            'query_type'     => 'get_var',
161
+            'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
162
+        );
163
+
164
+        return wpinv_price( (float) GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
165
+
166
+    }
167
+
168
+    /**
169
+     * Displays the total spent column.
170
+     *
171
+     * @since 1.0.19
172
+     *
173
+     * @param WP_User $user
174
+     *
175
+     * @return string Column Name
176
+     */
177
+    public function column_invoices( $user ) {
178
+
179
+        $args = array(
180
+            'data'             => array(
181
+
182
+                'ID'           => array(
183
+                    'type'     => 'post_data',
184
+                    'function' => 'COUNT',
185
+                    'name'     => 'count',
186
+                    'distinct' => true,
187
+                ),
188
+
189
+            ),
190
+            'where'            => array(
191
+
192
+                'author'       => array(
193
+                    'type'     => 'post_data',
194
+                    'value'    => absint( $user->ID ),
195
+                    'key'      => 'posts.post_author',
196
+                    'operator' => '=',
197
+                ),
198
+
199
+            ),
200
+            'query_type'     => 'get_var',
201
+            'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
202
+        );
203
+
204
+        return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
205
+
206
+    }
207
+
208
+    /**
209
+     * Generates content for a single row of the table
210
+     * @since 1.0.19
211
+     *
212
+     * @param int $item The user id.
213
+     */
214
+    public function single_row( $item ) {
215
+        $item = get_user_by( 'id', $item );
216
+
217
+        if ( empty( $item ) ) {
218
+            return;
219
+        }
220
+
221
+        echo '<tr>';
222
+        $this->single_row_columns( $item );
223
+        echo '</tr>';
224
+    }
225
+
226
+    /**
227
+     * Displays the customers name
228
+     *
229
+     * @param  WP_User $customer customer.
230
+     * @return string
231
+     */
232
+    public function column_name( $customer ) {
233
+
234
+        // Customer view URL.
235
+        $view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
236
+        $row_actions = $this->row_actions(
237
+            array(
238
+                'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
239
+            )
240
+        );
241
+
242
+        // Get user's address.
243
+        $address = wpinv_get_user_address( $customer->ID );
244
+
245
+        // Customer email address.
246
+        $email       = sanitize_email( $customer->user_email );
247
+
248
+        // Customer's avatar.
249
+        $avatar = esc_url( get_avatar_url( $email ) );
250
+        $avatar = "<img src='$avatar' height='32' width='32'/>";
251
+
252
+        // Customer's name.
253
+        $name   = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" );
254
+
255
+        if ( ! empty( $name ) ) {
256
+            $name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
257
+        }
258
+
259
+        $email = "<div class='row-title'><a href='$view_url'>$email</a></div>";
260
+
261
+        return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>";
262
+
263
+    }
264
+
265
+    /**
266
+     * Retrieve the table columns
267
+     *
268
+     * @since 1.0.19
269
+     * @return array $columns Array of all the list table columns
270
+     */
271
+    public function get_columns() {
272
+
273
+        $columns = array(
274
+            'name'     => __( 'Name', 'invoicing' ),
275
+            'country'  => __( 'Country', 'invoicing' ),
276
+            'state'    => __( 'State', 'invoicing' ),
277
+            'city'     => __( 'City', 'invoicing' ),
278
+            'zip'      => __( 'ZIP', 'invoicing' ),
279
+            'address'  => __( 'Address', 'invoicing' ),
280
+            'phone'    => __( 'Phone', 'invoicing' ),
281
+            'company'  => __( 'Company', 'invoicing' ),
282
+            'invoices' => __( 'Invoices', 'invoicing' ),
283
+            'total'    => __( 'Total Spend', 'invoicing' ),
284
+            'signup'   => __( 'Date created', 'invoicing' ),
285
+        );
286
+        return apply_filters( 'wpinv_customers_table_columns', $columns );
287
+
288
+    }
289
+
290
+    /**
291
+     * Retrieve the current page number
292
+     *
293
+     * @since 1.0.19
294
+     * @return int Current page number
295
+     */
296
+    public function get_paged() {
297
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
298
+    }
299
+
300
+    /**
301
+     * Returns bulk actions.
302
+     *
303
+     * @since 1.0.19
304
+     * @return void
305
+     */
306
+    public function bulk_actions( $which = '' ) {
307
+        return array();
308
+    }
309
+
310
+    /**
311
+     *  Prepares the display query
312
+     */
313
+    public function prepare_query() {
314
+        global $wpdb;
315
+
316
+        $post_types = 'WHERE ';
317
+
318
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
319
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
320
+        }
321
+
322
+        $post_types = rtrim( $post_types, ' OR' );
323
+
324
+        // Users with invoices.
325
+        $customers = $wpdb->get_col(
326
+            $wpdb->prepare(
327
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts $post_types LIMIT %d,%d",
328
+                $this->get_paged() * 10 - 10,
329
+                $this->per_page
330
+            )
331
+        );
332
+
333
+        $this->items = $customers;
334
+        $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types" );
335
+
336
+    }
337
+
338
+    /**
339
+     * Setup the final data for the table
340
+     *
341
+     * @since 1.0.19
342
+     * @return void
343
+     */
344
+    public function prepare_items() {
345
+        $columns               = $this->get_columns();
346
+        $hidden                = array(); // No hidden columns
347
+        $sortable              = $this->get_sortable_columns();
348
+        $this->_column_headers = array( $columns, $hidden, $sortable );
349
+        $this->prepare_query();
350
+
351
+        $this->set_pagination_args(
352
+            array(
353
+            'total_items' => $this->total,
354
+            'per_page'    => $this->per_page,
355
+            'total_pages' => ceil( $this->total / $this->per_page )
356
+            )
357
+        );
358
+
359
+    }
360 360
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if (!defined('ABSPATH')) exit;
9 9
 
10 10
 // Load WP_List_Table if not loaded
11
-if ( ! class_exists( 'WP_List_Table' ) ) {
11
+if (!class_exists('WP_List_Table')) {
12 12
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	public function __construct() {
43 43
 
44 44
 		// Set parent defaults
45
-		parent::__construct( array(
45
+		parent::__construct(array(
46 46
 			'singular' => 'id',
47 47
 			'plural'   => 'ids',
48 48
 			'ajax'     => false,
49
-		) );
49
+		));
50 50
 
51 51
 	}
52 52
 
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return string Column Name
74 74
 	 */
75
-	public function column_default( $item, $column_name ) {
76
-		$value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
77
-		return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
75
+	public function column_default($item, $column_name) {
76
+		$value = sanitize_text_field(get_user_meta($item->ID, '_wpinv_' . $column_name, true));
77
+		return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item);
78 78
 	}
79 79
 
80 80
 	/**
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return string Column Name
88 88
 	 */
89
-	public function column_country( $user ) {
90
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
91
-		if ( $country ) {
92
-			$country = wpinv_country_name( $country );
89
+	public function column_country($user) {
90
+		$country = wpinv_sanitize_country($user->_wpinv_country);
91
+		if ($country) {
92
+			$country = wpinv_country_name($country);
93 93
 		}
94
-		return sanitize_text_field( $country );
94
+		return sanitize_text_field($country);
95 95
 	}
96 96
 
97 97
 	/**
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return string Column Name
105 105
 	 */
106
-	public function column_state( $user ) {
107
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
106
+	public function column_state($user) {
107
+		$country = wpinv_sanitize_country($user->_wpinv_country);
108 108
 		$state   = $user->_wpinv_state;
109
-		if ( $state ) {
110
-			$state = wpinv_state_name( $state, $country );
109
+		if ($state) {
110
+			$state = wpinv_state_name($state, $country);
111 111
 		}
112 112
 
113
-		return sanitize_text_field( $state );
113
+		return sanitize_text_field($state);
114 114
 	}
115 115
 
116 116
 	/**
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return string Column Name
124 124
 	 */
125
-	public function column_signup( $user ) {
126
-		return getpaid_format_date_value( $user->user_registered );
125
+	public function column_signup($user) {
126
+		return getpaid_format_date_value($user->user_registered);
127 127
 	}
128 128
 
129 129
 	/**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @return string Column Name
137 137
 	 */
138
-	public function column_total( $user ) {
138
+	public function column_total($user) {
139 139
 
140 140
 		$args = array(
141 141
 			'data'             => array(
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
 
152 152
 				'author'       => array(
153 153
 					'type'     => 'post_data',
154
-					'value'    => absint( $user->ID ),
154
+					'value'    => absint($user->ID),
155 155
 					'key'      => 'posts.post_author',
156 156
 					'operator' => '=',
157 157
 				),
158 158
 
159 159
 			),
160 160
 			'query_type'     => 'get_var',
161
-			'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
161
+			'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'),
162 162
 		);
163 163
 
164
-		return wpinv_price( (float) GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
164
+		return wpinv_price((float) GetPaid_Reports_Helper::get_invoice_report_data($args));
165 165
 
166 166
 	}
167 167
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @return string Column Name
176 176
 	 */
177
-	public function column_invoices( $user ) {
177
+	public function column_invoices($user) {
178 178
 
179 179
 		$args = array(
180 180
 			'data'             => array(
@@ -191,17 +191,17 @@  discard block
 block discarded – undo
191 191
 
192 192
 				'author'       => array(
193 193
 					'type'     => 'post_data',
194
-					'value'    => absint( $user->ID ),
194
+					'value'    => absint($user->ID),
195 195
 					'key'      => 'posts.post_author',
196 196
 					'operator' => '=',
197 197
 				),
198 198
 
199 199
 			),
200 200
 			'query_type'     => 'get_var',
201
-			'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
201
+			'invoice_status' => array_keys(wpinv_get_invoice_statuses()),
202 202
 		);
203 203
 
204
-		return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
204
+		return absint(GetPaid_Reports_Helper::get_invoice_report_data($args));
205 205
 
206 206
 	}
207 207
 
@@ -211,15 +211,15 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @param int $item The user id.
213 213
 	 */
214
-	public function single_row( $item ) {
215
-		$item = get_user_by( 'id', $item );
214
+	public function single_row($item) {
215
+		$item = get_user_by('id', $item);
216 216
 
217
-		if ( empty( $item ) ) {
217
+		if (empty($item)) {
218 218
 			return;
219 219
 		}
220 220
 
221 221
 		echo '<tr>';
222
-		$this->single_row_columns( $item );
222
+		$this->single_row_columns($item);
223 223
 		echo '</tr>';
224 224
 	}
225 225
 
@@ -229,30 +229,30 @@  discard block
 block discarded – undo
229 229
 	 * @param  WP_User $customer customer.
230 230
 	 * @return string
231 231
 	 */
232
-	public function column_name( $customer ) {
232
+	public function column_name($customer) {
233 233
 
234 234
 		// Customer view URL.
235
-		$view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
235
+		$view_url    = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php')));
236 236
 		$row_actions = $this->row_actions(
237 237
 			array(
238
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
238
+				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>',
239 239
 			)
240 240
 		);
241 241
 
242 242
 		// Get user's address.
243
-		$address = wpinv_get_user_address( $customer->ID );
243
+		$address = wpinv_get_user_address($customer->ID);
244 244
 
245 245
 		// Customer email address.
246
-		$email       = sanitize_email( $customer->user_email );
246
+		$email = sanitize_email($customer->user_email);
247 247
 
248 248
 		// Customer's avatar.
249
-		$avatar = esc_url( get_avatar_url( $email ) );
249
+		$avatar = esc_url(get_avatar_url($email));
250 250
 		$avatar = "<img src='$avatar' height='32' width='32'/>";
251 251
 
252 252
 		// Customer's name.
253
-		$name   = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" );
253
+		$name   = sanitize_text_field("{$address['first_name']} {$address['last_name']}");
254 254
 
255
-		if ( ! empty( $name ) ) {
255
+		if (!empty($name)) {
256 256
 			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
257 257
 		}
258 258
 
@@ -271,19 +271,19 @@  discard block
 block discarded – undo
271 271
 	public function get_columns() {
272 272
 
273 273
 		$columns = array(
274
-			'name'     => __( 'Name', 'invoicing' ),
275
-			'country'  => __( 'Country', 'invoicing' ),
276
-			'state'    => __( 'State', 'invoicing' ),
277
-			'city'     => __( 'City', 'invoicing' ),
278
-			'zip'      => __( 'ZIP', 'invoicing' ),
279
-			'address'  => __( 'Address', 'invoicing' ),
280
-			'phone'    => __( 'Phone', 'invoicing' ),
281
-			'company'  => __( 'Company', 'invoicing' ),
282
-			'invoices' => __( 'Invoices', 'invoicing' ),
283
-			'total'    => __( 'Total Spend', 'invoicing' ),
284
-			'signup'   => __( 'Date created', 'invoicing' ),
274
+			'name'     => __('Name', 'invoicing'),
275
+			'country'  => __('Country', 'invoicing'),
276
+			'state'    => __('State', 'invoicing'),
277
+			'city'     => __('City', 'invoicing'),
278
+			'zip'      => __('ZIP', 'invoicing'),
279
+			'address'  => __('Address', 'invoicing'),
280
+			'phone'    => __('Phone', 'invoicing'),
281
+			'company'  => __('Company', 'invoicing'),
282
+			'invoices' => __('Invoices', 'invoicing'),
283
+			'total'    => __('Total Spend', 'invoicing'),
284
+			'signup'   => __('Date created', 'invoicing'),
285 285
 		);
286
-		return apply_filters( 'wpinv_customers_table_columns', $columns );
286
+		return apply_filters('wpinv_customers_table_columns', $columns);
287 287
 
288 288
 	}
289 289
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 * @return int Current page number
295 295
 	 */
296 296
 	public function get_paged() {
297
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
297
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
298 298
 	}
299 299
 
300 300
 	/**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	 * @since 1.0.19
304 304
 	 * @return void
305 305
 	 */
306
-	public function bulk_actions( $which = '' ) {
306
+	public function bulk_actions($which = '') {
307 307
 		return array();
308 308
 	}
309 309
 
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 
316 316
 		$post_types = 'WHERE ';
317 317
 
318
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
319
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
318
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
319
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
320 320
 		}
321 321
 
322
-		$post_types = rtrim( $post_types, ' OR' );
322
+		$post_types = rtrim($post_types, ' OR');
323 323
 
324 324
 		// Users with invoices.
325 325
     	$customers = $wpdb->get_col(
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		);
332 332
 
333 333
 		$this->items = $customers;
334
-		$this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types" );
334
+		$this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types");
335 335
 
336 336
 	}
337 337
 
@@ -345,14 +345,14 @@  discard block
 block discarded – undo
345 345
 		$columns               = $this->get_columns();
346 346
 		$hidden                = array(); // No hidden columns
347 347
 		$sortable              = $this->get_sortable_columns();
348
-		$this->_column_headers = array( $columns, $hidden, $sortable );
348
+		$this->_column_headers = array($columns, $hidden, $sortable);
349 349
 		$this->prepare_query();
350 350
 
351 351
 		$this->set_pagination_args(
352 352
 			array(
353 353
 			'total_items' => $this->total,
354 354
 			'per_page'    => $this->per_page,
355
-			'total_pages' => ceil( $this->total / $this->per_page )
355
+			'total_pages' => ceil($this->total / $this->per_page)
356 356
 			)
357 357
 		);
358 358
 
Please login to merge, or discard this patch.