Passed
Push — master ( 96fb7a...3da2df )
by Brian
04:36
created
includes/admin/class-wpinv-customers-table.php 1 patch
Spacing   +51 added lines, -51 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,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return string Column Name
124 124
 	 */
125
-	public function column_total( $user ) {
125
+	public function column_total($user) {
126 126
 
127 127
 		$args = array(
128 128
 			'data'             => array(
@@ -138,17 +138,17 @@  discard block
 block discarded – undo
138 138
 
139 139
 				'author'       => array(
140 140
 					'type'     => 'post_data',
141
-					'value'    => absint( $user->ID ),
141
+					'value'    => absint($user->ID),
142 142
 					'key'      => 'posts.post_author',
143 143
 					'operator' => '=',
144 144
 				),
145 145
 
146 146
 			),
147 147
 			'query_type'     => 'get_var',
148
-			'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
148
+			'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'),
149 149
 		);
150 150
 
151
-		return wpinv_price( (float) GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
151
+		return wpinv_price((float) GetPaid_Reports_Helper::get_invoice_report_data($args));
152 152
 
153 153
 	}
154 154
 
@@ -158,15 +158,15 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @param int $item The user id.
160 160
 	 */
161
-	public function single_row( $item ) {
162
-		$item = get_user_by( 'id', $item );
161
+	public function single_row($item) {
162
+		$item = get_user_by('id', $item);
163 163
 
164
-		if ( empty( $item ) ) {
164
+		if (empty($item)) {
165 165
 			return;
166 166
 		}
167 167
 
168 168
 		echo '<tr>';
169
-		$this->single_row_columns( $item );
169
+		$this->single_row_columns($item);
170 170
 		echo '</tr>';
171 171
 	}
172 172
 
@@ -176,30 +176,30 @@  discard block
 block discarded – undo
176 176
 	 * @param  WP_User $customer customer.
177 177
 	 * @return string
178 178
 	 */
179
-	public function column_name( $customer ) {
179
+	public function column_name($customer) {
180 180
 
181 181
 		// Customer view URL.
182
-		$view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
182
+		$view_url    = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php')));
183 183
 		$row_actions = $this->row_actions(
184 184
 			array(
185
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
185
+				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>',
186 186
 			)
187 187
 		);
188 188
 
189 189
 		// Get user's address.
190
-		$address = wpinv_get_user_address( $customer->ID );
190
+		$address = wpinv_get_user_address($customer->ID);
191 191
 
192 192
 		// Customer email address.
193
-		$email       = sanitize_email( $customer->user_email );
193
+		$email = sanitize_email($customer->user_email);
194 194
 
195 195
 		// Customer's avatar.
196
-		$avatar = esc_url( get_avatar_url( $email ) );
196
+		$avatar = esc_url(get_avatar_url($email));
197 197
 		$avatar = "<img src='$avatar' height='32' width='32'/>";
198 198
 
199 199
 		// Customer's name.
200
-		$name   = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" );
200
+		$name   = sanitize_text_field("{$address['first_name']} {$address['last_name']}");
201 201
 
202
-		if ( ! empty( $name ) ) {
202
+		if (!empty($name)) {
203 203
 			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
204 204
 		}
205 205
 
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
 	public function get_columns() {
219 219
 
220 220
 		$columns = array(
221
-			'name'     => __( 'Name', 'invoicing' ),
222
-			'country'  => __( 'Country', 'invoicing' ),
223
-			'state'    => __( 'State', 'invoicing' ),
224
-			'city'     => __( 'City', 'invoicing' ),
225
-			'zip'      => __( 'ZIP', 'invoicing' ),
226
-			'address'  => __( 'Address', 'invoicing' ),
227
-			'phone'    => __( 'Phone', 'invoicing' ),
228
-			'company'  => __( 'Company', 'invoicing' ),
229
-			'total'    => __( 'Total Spend', 'invoicing' ),
221
+			'name'     => __('Name', 'invoicing'),
222
+			'country'  => __('Country', 'invoicing'),
223
+			'state'    => __('State', 'invoicing'),
224
+			'city'     => __('City', 'invoicing'),
225
+			'zip'      => __('ZIP', 'invoicing'),
226
+			'address'  => __('Address', 'invoicing'),
227
+			'phone'    => __('Phone', 'invoicing'),
228
+			'company'  => __('Company', 'invoicing'),
229
+			'total'    => __('Total Spend', 'invoicing'),
230 230
 		);
231
-		return apply_filters( 'wpinv_customers_table_columns', $columns );
231
+		return apply_filters('wpinv_customers_table_columns', $columns);
232 232
 
233 233
 	}
234 234
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * @return int Current page number
240 240
 	 */
241 241
 	public function get_paged() {
242
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
242
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
243 243
 	}
244 244
 
245 245
 	/**
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 * @since 1.0.19
249 249
 	 * @return void
250 250
 	 */
251
-	public function bulk_actions( $which = '' ) {
251
+	public function bulk_actions($which = '') {
252 252
 		return array();
253 253
 	}
254 254
 
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 
261 261
 		$post_types = 'WHERE ';
262 262
 
263
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
264
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
263
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
264
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
265 265
 		}
266 266
 
267
-		$post_types = rtrim( $post_types, ' OR' );
267
+		$post_types = rtrim($post_types, ' OR');
268 268
 
269 269
 		// Users with invoices.
270 270
     	$customers = $wpdb->get_col(
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 		);
277 277
 
278 278
 		$this->items = $customers;
279
-		$this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types" );
279
+		$this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types");
280 280
 
281 281
 	}
282 282
 
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 		$columns               = $this->get_columns();
291 291
 		$hidden                = array(); // No hidden columns
292 292
 		$sortable              = $this->get_sortable_columns();
293
-		$this->_column_headers = array( $columns, $hidden, $sortable );
293
+		$this->_column_headers = array($columns, $hidden, $sortable);
294 294
 		$this->prepare_query();
295 295
 
296 296
 		$this->set_pagination_args(
297 297
 			array(
298 298
 			'total_items' => $this->total,
299 299
 			'per_page'    => $this->per_page,
300
-			'total_pages' => ceil( $this->total / $this->per_page )
300
+			'total_pages' => ceil($this->total / $this->per_page)
301 301
 			)
302 302
 		);
303 303
 
Please login to merge, or discard this patch.