Passed
Push — master ( 738f2e...6e5162 )
by Brian
10:01
created
includes/class-getpaid-customers-query.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @param null|string|array $query Optional. The query variables.
99 99
 	 */
100
-	public function __construct( $query = null ) {
101
-		if ( ! is_null( $query ) ) {
102
-			$this->prepare_query( $query );
100
+	public function __construct($query = null) {
101
+		if (!is_null($query)) {
102
+			$this->prepare_query($query);
103 103
 			$this->query();
104 104
 		}
105 105
 	}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @param  string|array $args Query vars, as passed to `GetPaid_Subscriptions_Query`.
113 113
 	 * @return array Complete query variables with undefined ones filled in with defaults.
114 114
 	 */
115
-	public static function fill_query_vars( $args ) {
115
+	public static function fill_query_vars($args) {
116 116
 		$defaults = array(
117 117
 			'include'     => array(),
118 118
 			'exclude'     => array(),
@@ -126,16 +126,16 @@  discard block
 block discarded – undo
126 126
 			's'           => '',
127 127
 		);
128 128
 
129
-		foreach ( GetPaid_Customer_Data_Store::get_database_fields() as $field => $type ) {
130
-			$defaults[ $field ] = 'any';
129
+		foreach (GetPaid_Customer_Data_Store::get_database_fields() as $field => $type) {
130
+			$defaults[$field] = 'any';
131 131
 
132
-			if ( '%f' === $type || '%d' === $type ) {
133
-				$defaults[ $field . '_min' ] = '';
134
-				$defaults[ $field . '_max' ] = '';
132
+			if ('%f' === $type || '%d' === $type) {
133
+				$defaults[$field . '_min'] = '';
134
+				$defaults[$field . '_max'] = '';
135 135
 			}
136 136
 		}
137 137
 
138
-		return wp_parse_args( $args, $defaults );
138
+		return wp_parse_args($args, $defaults);
139 139
 	}
140 140
 
141 141
 	/**
@@ -145,45 +145,45 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @see self::fill_query_vars() For allowede args and their defaults.
147 147
 	 */
148
-	public function prepare_query( $query = array() ) {
148
+	public function prepare_query($query = array()) {
149 149
 		global $wpdb;
150 150
 
151
-		if ( empty( $this->query_vars ) || ! empty( $query ) ) {
151
+		if (empty($this->query_vars) || !empty($query)) {
152 152
 			$this->query_limit = null;
153
-			$this->query_vars  = $this->fill_query_vars( $query );
153
+			$this->query_vars  = $this->fill_query_vars($query);
154 154
 		}
155 155
 
156
-		if ( ! empty( $this->query_vars['fields'] ) && 'all' !== $this->query_vars['fields'] ) {
157
-			$this->query_vars['fields'] = wpinv_parse_list( $this->query_vars['fields'] );
156
+		if (!empty($this->query_vars['fields']) && 'all' !== $this->query_vars['fields']) {
157
+			$this->query_vars['fields'] = wpinv_parse_list($this->query_vars['fields']);
158 158
 		}
159 159
 
160
-		do_action( 'getpaid_pre_get_customers', array( &$this ) );
160
+		do_action('getpaid_pre_get_customers', array(&$this));
161 161
 
162 162
 		// Ensure that query vars are filled after 'getpaid_pre_get_customers'.
163 163
 		$qv                = & $this->query_vars;
164
-		$qv                = $this->fill_query_vars( $qv );
164
+		$qv                = $this->fill_query_vars($qv);
165 165
 		$table             = $wpdb->prefix . 'getpaid_customers';
166 166
 		$this->query_from  = "FROM $table";
167 167
 
168 168
 		// Prepare query fields.
169
-		$this->prepare_query_fields( $qv, $table );
169
+		$this->prepare_query_fields($qv, $table);
170 170
 
171 171
 		// Prepare query where.
172
-		$this->prepare_query_where( $qv, $table );
172
+		$this->prepare_query_where($qv, $table);
173 173
 
174 174
 		// Prepare query order.
175
-		$this->prepare_query_order( $qv, $table );
175
+		$this->prepare_query_order($qv, $table);
176 176
 
177 177
 		// limit
178
-		if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
179
-			if ( $qv['offset'] ) {
180
-				$this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] );
178
+		if (isset($qv['number']) && $qv['number'] > 0) {
179
+			if ($qv['offset']) {
180
+				$this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['offset'], $qv['number']);
181 181
 			} else {
182
-				$this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] );
182
+				$this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['number'] * ($qv['paged'] - 1), $qv['number']);
183 183
 			}
184 184
 		}
185 185
 
186
-		do_action_ref_array( 'getpaid_after_customers_query', array( &$this ) );
186
+		do_action_ref_array('getpaid_after_customers_query', array(&$this));
187 187
 	}
188 188
 
189 189
 	/**
@@ -194,27 +194,27 @@  discard block
 block discarded – undo
194 194
 	 * @param array $qv Query vars.
195 195
 	 * @param string $table Table name.
196 196
 	 */
197
-	protected function prepare_query_fields( &$qv, $table ) {
197
+	protected function prepare_query_fields(&$qv, $table) {
198 198
 
199
-		if ( is_array( $qv['fields'] ) ) {
200
-			$qv['fields']   = array_unique( $qv['fields'] );
201
-			$allowed_fields = array_keys( GetPaid_Customer_Data_Store::get_database_fields() );
199
+		if (is_array($qv['fields'])) {
200
+			$qv['fields']   = array_unique($qv['fields']);
201
+			$allowed_fields = array_keys(GetPaid_Customer_Data_Store::get_database_fields());
202 202
 
203 203
 			$query_fields = array();
204
-			foreach ( $qv['fields'] as $field ) {
205
-				if ( ! in_array( $field, $allowed_fields ) ) {
204
+			foreach ($qv['fields'] as $field) {
205
+				if (!in_array($field, $allowed_fields)) {
206 206
 					continue;
207 207
 				}
208 208
 
209
-				$field          = sanitize_key( $field );
209
+				$field          = sanitize_key($field);
210 210
 				$query_fields[] = "$table.`$field`";
211 211
 			}
212
-			$this->query_fields = implode( ',', $query_fields );
212
+			$this->query_fields = implode(',', $query_fields);
213 213
 		} else {
214 214
 			$this->query_fields = "$table.*";
215 215
 		}
216 216
 
217
-		if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
217
+		if (isset($qv['count_total']) && $qv['count_total']) {
218 218
 			$this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
219 219
 		}
220 220
 
@@ -228,55 +228,55 @@  discard block
 block discarded – undo
228 228
 	 * @param array $qv Query vars.
229 229
 	 * @param string $table Table name.
230 230
 	 */
231
-	protected function prepare_query_where( &$qv, $table ) {
231
+	protected function prepare_query_where(&$qv, $table) {
232 232
 		global $wpdb;
233 233
 		$this->query_where = 'WHERE 1=1';
234 234
 
235 235
 		// Fields.
236
-		foreach ( GetPaid_Customer_Data_Store::get_database_fields() as $field => $type ) {
237
-			if ( 'any' !== $qv[ $field ] ) {
236
+		foreach (GetPaid_Customer_Data_Store::get_database_fields() as $field => $type) {
237
+			if ('any' !== $qv[$field]) {
238 238
 
239 239
 				// In.
240
-				if ( is_array( $qv[ $field ] ) ) {
241
-					$in                 = join( ',', array_fill( 0, count( $qv[ $field ] ), $type ) );
242
-					$this->query_where .= $wpdb->prepare( " AND $table.`status` IN ( $in )", $qv[ $field ] );
243
-				} elseif ( ! empty( $qv[ $field ] ) ) {
244
-					$this->query_where .= $wpdb->prepare( " AND $table.`$field` = $type", $qv[ $field ] );
240
+				if (is_array($qv[$field])) {
241
+					$in                 = join(',', array_fill(0, count($qv[$field]), $type));
242
+					$this->query_where .= $wpdb->prepare(" AND $table.`status` IN ( $in )", $qv[$field]);
243
+				} elseif (!empty($qv[$field])) {
244
+					$this->query_where .= $wpdb->prepare(" AND $table.`$field` = $type", $qv[$field]);
245 245
 				}
246 246
 			}
247 247
 
248 248
 			// Min/Max.
249
-			if ( '%f' === $type || '%d' === $type ) {
249
+			if ('%f' === $type || '%d' === $type) {
250 250
 
251 251
 				// Min.
252
-				if ( is_numeric( $qv[ $field . '_min' ] ) ) {
253
-					$this->query_where .= $wpdb->prepare( " AND $table.`$field` >= $type", $qv[ $field . '_min' ] );
252
+				if (is_numeric($qv[$field . '_min'])) {
253
+					$this->query_where .= $wpdb->prepare(" AND $table.`$field` >= $type", $qv[$field . '_min']);
254 254
 				}
255 255
 
256 256
 				// Max.
257
-				if ( is_numeric( $qv[ $field . '_max' ] ) ) {
258
-					$this->query_where .= $wpdb->prepare( " AND $table.`$field` <= $type", $qv[ $field . '_max' ] );
257
+				if (is_numeric($qv[$field . '_max'])) {
258
+					$this->query_where .= $wpdb->prepare(" AND $table.`$field` <= $type", $qv[$field . '_max']);
259 259
 				}
260 260
 			}
261 261
 		}
262 262
 
263
-		if ( ! empty( $qv['include'] ) ) {
264
-			$include            = implode( ',', wp_parse_id_list( $qv['include'] ) );
263
+		if (!empty($qv['include'])) {
264
+			$include            = implode(',', wp_parse_id_list($qv['include']));
265 265
 			$this->query_where .= " AND $table.`id` IN ($include)";
266
-		} elseif ( ! empty( $qv['exclude'] ) ) {
267
-			$exclude            = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
266
+		} elseif (!empty($qv['exclude'])) {
267
+			$exclude            = implode(',', wp_parse_id_list($qv['exclude']));
268 268
 			$this->query_where .= " AND $table.`id` NOT IN ($exclude)";
269 269
 		}
270 270
 
271 271
 		// Date queries are allowed for the customer creation date.
272
-		if ( ! empty( $qv['date_created_query'] ) && is_array( $qv['date_created_query'] ) ) {
273
-			$date_created_query = new WP_Date_Query( $qv['date_created_query'], "$table.date_created" );
272
+		if (!empty($qv['date_created_query']) && is_array($qv['date_created_query'])) {
273
+			$date_created_query = new WP_Date_Query($qv['date_created_query'], "$table.date_created");
274 274
 			$this->query_where .= $date_created_query->get_sql();
275 275
 		}
276 276
 
277 277
 		// Search.
278
-		if ( ! empty( $qv['s'] ) ) {
279
-			$this->query_where .= $this->get_search_sql( $qv['s'] );
278
+		if (!empty($qv['s'])) {
279
+			$this->query_where .= $this->get_search_sql($qv['s']);
280 280
 		}
281 281
 	}
282 282
 
@@ -290,22 +290,22 @@  discard block
 block discarded – undo
290 290
 	 * @param string $string The string to search for.
291 291
 	 * @return string
292 292
 	 */
293
-	protected function get_search_sql( $string ) {
293
+	protected function get_search_sql($string) {
294 294
 		global $wpdb;
295 295
 
296 296
 		$searches = array();
297
-		$string   = trim( $string, '%' );
298
-		$like     = '%' . $wpdb->esc_like( $string ) . '%';
297
+		$string   = trim($string, '%');
298
+		$like     = '%' . $wpdb->esc_like($string) . '%';
299 299
 
300
-		foreach ( array_keys( GetPaid_Customer_Data_Store::get_database_fields() ) as $col ) {
301
-			if ( 'id' === $col || 'user_id' === $col ) {
302
-				$searches[] = $wpdb->prepare( "$col = %s", $string );  // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
300
+		foreach (array_keys(GetPaid_Customer_Data_Store::get_database_fields()) as $col) {
301
+			if ('id' === $col || 'user_id' === $col) {
302
+				$searches[] = $wpdb->prepare("$col = %s", $string); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
303 303
 			} else {
304
-				$searches[] = $wpdb->prepare( "$col LIKE %s", $like );  // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
304
+				$searches[] = $wpdb->prepare("$col LIKE %s", $like); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
305 305
 			}
306 306
 		}
307 307
 
308
-		return ' AND (' . implode( ' OR ', $searches ) . ')';
308
+		return ' AND (' . implode(' OR ', $searches) . ')';
309 309
 	}
310 310
 
311 311
 	/**
@@ -316,24 +316,24 @@  discard block
 block discarded – undo
316 316
 	 * @param array $qv Query vars.
317 317
 	 * @param string $table Table name.
318 318
 	 */
319
-	protected function prepare_query_order( &$qv, $table ) {
319
+	protected function prepare_query_order(&$qv, $table) {
320 320
 
321 321
 		// sorting.
322
-		$qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : '';
323
-		$order       = $this->parse_order( $qv['order'] );
322
+		$qv['order'] = isset($qv['order']) ? strtoupper($qv['order']) : '';
323
+		$order       = $this->parse_order($qv['order']);
324 324
 
325 325
 		// Default order is by 'id' (latest customers).
326
-		if ( empty( $qv['orderby'] ) ) {
327
-			$qv['orderby'] = array( 'id' );
326
+		if (empty($qv['orderby'])) {
327
+			$qv['orderby'] = array('id');
328 328
 		}
329 329
 
330 330
 		// 'orderby' values may be an array, comma- or space-separated list.
331
-		$ordersby      = array_filter( wpinv_parse_list( $qv['orderby'] ) );
331
+		$ordersby      = array_filter(wpinv_parse_list($qv['orderby']));
332 332
 
333 333
 		$orderby_array = array();
334
-		foreach ( $ordersby as $_key => $_value ) {
334
+		foreach ($ordersby as $_key => $_value) {
335 335
 
336
-			if ( is_int( $_key ) ) {
336
+			if (is_int($_key)) {
337 337
 				// Integer key means this is a flat array of 'orderby' fields.
338 338
 				$_orderby = $_value;
339 339
 				$_order   = $order;
@@ -343,19 +343,19 @@  discard block
 block discarded – undo
343 343
 				$_order   = $_value;
344 344
 			}
345 345
 
346
-			$parsed = $this->parse_orderby( $_orderby, $table );
346
+			$parsed = $this->parse_orderby($_orderby, $table);
347 347
 
348
-			if ( $parsed ) {
349
-				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
348
+			if ($parsed) {
349
+				$orderby_array[] = $parsed . ' ' . $this->parse_order($_order);
350 350
 			}
351 351
 		}
352 352
 
353 353
 		// If no valid clauses were found, order by id.
354
-		if ( empty( $orderby_array ) ) {
354
+		if (empty($orderby_array)) {
355 355
 			$orderby_array[] = "id $order";
356 356
 		}
357 357
 
358
-		$this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array );
358
+		$this->query_orderby = 'ORDER BY ' . implode(', ', $orderby_array);
359 359
 
360 360
 	}
361 361
 
@@ -369,33 +369,33 @@  discard block
 block discarded – undo
369 369
 	public function query() {
370 370
 		global $wpdb;
371 371
 
372
-		$qv =& $this->query_vars;
372
+		$qv = & $this->query_vars;
373 373
 
374 374
 		// Return a non-null value to bypass the default GetPaid customers query and remember to set the
375 375
 		// total_customers property.
376
-		$this->results = apply_filters_ref_array( 'getpaid_customers_pre_query', array( null, &$this ) );
376
+		$this->results = apply_filters_ref_array('getpaid_customers_pre_query', array(null, &$this));
377 377
 
378
-		if ( null === $this->results ) {
378
+		if (null === $this->results) {
379 379
 			$this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";
380 380
 
381
-			if ( ( is_array( $qv['fields'] ) && 1 !== count( $qv['fields'] ) ) || 'all' === $qv['fields'] ) {
382
-				$this->results = $wpdb->get_results( $this->request );
381
+			if ((is_array($qv['fields']) && 1 !== count($qv['fields'])) || 'all' === $qv['fields']) {
382
+				$this->results = $wpdb->get_results($this->request);
383 383
 			} else {
384
-				$this->results = $wpdb->get_col( $this->request );
384
+				$this->results = $wpdb->get_col($this->request);
385 385
 			}
386 386
 
387
-			if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
388
-				$found_customers_query = apply_filters( 'getpaid_found_customers_query', 'SELECT FOUND_ROWS()', $this );
389
-				$this->total_customers = (int) $wpdb->get_var( $found_customers_query );
387
+			if (isset($qv['count_total']) && $qv['count_total']) {
388
+				$found_customers_query = apply_filters('getpaid_found_customers_query', 'SELECT FOUND_ROWS()', $this);
389
+				$this->total_customers = (int) $wpdb->get_var($found_customers_query);
390 390
 			}
391 391
 		}
392 392
 
393
-		if ( 'all' === $qv['fields'] ) {
394
-			foreach ( $this->results as $key => $customer ) {
395
-				$this->set_cache( $customer->id, $customer, 'getpaid_customers' );
396
-				$this->set_cache( $customer->user_id, $customer->id, 'getpaid_customer_ids_by_user_id' );
397
-				$this->set_cache( $customer->email, $customer->id, 'getpaid_customer_ids_by_email' );
398
-				$this->results[ $key ] = new GetPaid_Customer( $customer );
393
+		if ('all' === $qv['fields']) {
394
+			foreach ($this->results as $key => $customer) {
395
+				$this->set_cache($customer->id, $customer, 'getpaid_customers');
396
+				$this->set_cache($customer->user_id, $customer->id, 'getpaid_customer_ids_by_user_id');
397
+				$this->set_cache($customer->email, $customer->id, 'getpaid_customer_ids_by_email');
398
+				$this->results[$key] = new GetPaid_Customer($customer);
399 399
 			}
400 400
 		}
401 401
 
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
 	 * @param integer $expire
411 411
 	 * @return boolean
412 412
 	 */
413
-	public function set_cache( $key, $data, $group = '', $expire = 0 ) {
413
+	public function set_cache($key, $data, $group = '', $expire = 0) {
414 414
 
415
-		if ( empty( $key ) ) {
415
+		if (empty($key)) {
416 416
 			return false;
417 417
 		}
418 418
 
419
-		wp_cache_set( $key, $data, $group, $expire );
419
+		wp_cache_set($key, $data, $group, $expire);
420 420
 	}
421 421
 
422 422
 	/**
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 	 * @param string $query_var Query variable key.
428 428
 	 * @return mixed
429 429
 	 */
430
-	public function get( $query_var ) {
431
-		if ( isset( $this->query_vars[ $query_var ] ) ) {
432
-			return $this->query_vars[ $query_var ];
430
+	public function get($query_var) {
431
+		if (isset($this->query_vars[$query_var])) {
432
+			return $this->query_vars[$query_var];
433 433
 		}
434 434
 
435 435
 		return null;
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 * @param string $query_var Query variable key.
444 444
 	 * @param mixed $value Query variable value.
445 445
 	 */
446
-	public function set( $query_var, $value ) {
447
-		$this->query_vars[ $query_var ] = $value;
446
+	public function set($query_var, $value) {
447
+		$this->query_vars[$query_var] = $value;
448 448
 	}
449 449
 
450 450
 	/**
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
 	 *  @param string $table The current table.
479 479
 	 * @return string Value to use in the ORDER clause, if `$orderby` is valid.
480 480
 	 */
481
-	protected function parse_orderby( $orderby, $table ) {
481
+	protected function parse_orderby($orderby, $table) {
482 482
 
483 483
 		$_orderby = '';
484
-		if ( in_array( $orderby, array_keys( GetPaid_Customer_Data_Store::get_database_fields() ), true ) ) {
484
+		if (in_array($orderby, array_keys(GetPaid_Customer_Data_Store::get_database_fields()), true)) {
485 485
 			$_orderby = "$table.`$orderby`";
486
-		} elseif ( 'id' === strtolower( $orderby ) ) {
486
+		} elseif ('id' === strtolower($orderby)) {
487 487
 			$_orderby = "$table.id";
488
-		} elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) {
489
-			$include     = wp_parse_id_list( $this->query_vars['include'] );
490
-			$include_sql = implode( ',', $include );
488
+		} elseif ('include' === $orderby && !empty($this->query_vars['include'])) {
489
+			$include     = wp_parse_id_list($this->query_vars['include']);
490
+			$include_sql = implode(',', $include);
491 491
 			$_orderby    = "FIELD( $table.id, $include_sql )";
492 492
 		}
493 493
 
@@ -502,12 +502,12 @@  discard block
 block discarded – undo
502 502
 	 * @param string $order The 'order' query variable.
503 503
 	 * @return string The sanitized 'order' query variable.
504 504
 	 */
505
-	protected function parse_order( $order ) {
506
-		if ( ! is_string( $order ) || empty( $order ) ) {
505
+	protected function parse_order($order) {
506
+		if (!is_string($order) || empty($order)) {
507 507
 			return 'DESC';
508 508
 		}
509 509
 
510
-		if ( 'ASC' === strtoupper( $order ) ) {
510
+		if ('ASC' === strtoupper($order)) {
511 511
 			return 'ASC';
512 512
 		} else {
513 513
 			return 'DESC';
Please login to merge, or discard this patch.
includes/admin/class-getpaid-installer.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   2.0.2
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * The main installer/updater class.
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @param string $upgrade_from The current invoicing version.
27 27
 	 */
28
-	public function upgrade_db( $upgrade_from ) {
28
+	public function upgrade_db($upgrade_from) {
29 29
 
30 30
 		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
31
+		update_option('wpinv_version', WPINV_VERSION);
32 32
 
33 33
 		// Setup the invoice Custom Post Type.
34 34
 		GetPaid_Post_Types::register_post_types();
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		// Create any missing database tables.
49 49
 		$method = "upgrade_from_$upgrade_from";
50 50
 
51
-		$installed = get_option( 'gepaid_installed_on' );
51
+		$installed = get_option('gepaid_installed_on');
52 52
 
53
-		if ( empty( $installed ) ) {
54
-			update_option( 'gepaid_installed_on', time() );
53
+		if (empty($installed)) {
54
+			update_option('gepaid_installed_on', time());
55 55
 		}
56 56
 
57
-		if ( method_exists( $this, $method ) ) {
57
+		if (method_exists($this, $method)) {
58 58
 			$this->$method();
59 59
 		}
60 60
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	public function upgrade_from_0() {
68 68
 
69 69
 		// Save default tax rates.
70
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
70
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,27 +78,27 @@  discard block
 block discarded – undo
78 78
 		global $wpdb;
79 79
 
80 80
 		// Invoices.
81
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
82
-		if ( ! empty( $results ) ) {
83
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
81
+		$results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
82
+		if (!empty($results)) {
83
+			$wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
84 84
 
85 85
 			// Clean post cache
86
-			foreach ( $results as $row ) {
87
-				clean_post_cache( $row->ID );
86
+			foreach ($results as $row) {
87
+				clean_post_cache($row->ID);
88 88
 			}
89 89
 		}
90 90
 
91 91
 		// Item meta key changes
92 92
 		$query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
93
-		$results = $wpdb->get_results( $query );
93
+		$results = $wpdb->get_results($query);
94 94
 
95
-		if ( ! empty( $results ) ) {
96
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
97
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
98
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
95
+		if (!empty($results)) {
96
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
97
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
98
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
99 99
 
100
-			foreach ( $results as $row ) {
101
-				clean_post_cache( $row->post_id );
100
+			foreach ($results as $row) {
101
+				clean_post_cache($row->post_id);
102 102
 			}
103 103
 		}
104 104
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 */
129 129
 	public function add_capabilities() {
130
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
130
+		$GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing');
131 131
 	}
132 132
 
133 133
 	/**
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 
143 143
 				// Checkout page.
144 144
 				'checkout_page'             => array(
145
-					'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
146
-					'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
145
+					'name'    => _x('gp-checkout', 'Page slug', 'invoicing'),
146
+					'title'   => _x('Checkout', 'Page title', 'invoicing'),
147 147
 					'content' => '
148 148
 						<!-- wp:shortcode -->
149 149
 						[wpinv_checkout]
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
 				// Invoice history page.
156 156
 				'invoice_history_page'      => array(
157
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
158
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
157
+					'name'    => _x('gp-invoices', 'Page slug', 'invoicing'),
158
+					'title'   => _x('My Invoices', 'Page title', 'invoicing'),
159 159
 					'content' => '
160 160
 					<!-- wp:shortcode -->
161 161
 					[wpinv_history]
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 
167 167
 				// Success page content.
168 168
 				'success_page'              => array(
169
-					'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
170
-					'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
169
+					'name'    => _x('gp-receipt', 'Page slug', 'invoicing'),
170
+					'title'   => _x('Payment Confirmation', 'Page title', 'invoicing'),
171 171
 					'content' => '
172 172
 					<!-- wp:shortcode -->
173 173
 					[wpinv_receipt]
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
 
179 179
 				// Failure page content.
180 180
 				'failure_page'              => array(
181
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
182
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
183
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
181
+					'name'    => _x('gp-transaction-failed', 'Page slug', 'invoicing'),
182
+					'title'   => _x('Transaction Failed', 'Page title', 'invoicing'),
183
+					'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'),
184 184
 					'parent'  => 'gp-checkout',
185 185
 				),
186 186
 
187 187
 				// Subscriptions history page.
188 188
 				'invoice_subscription_page' => array(
189
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
190
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
189
+					'name'    => _x('gp-subscriptions', 'Page slug', 'invoicing'),
190
+					'title'   => _x('My Subscriptions', 'Page title', 'invoicing'),
191 191
 					'content' => '
192 192
 					<!-- wp:shortcode -->
193 193
 					[wpinv_subscriptions]
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	public function create_pages() {
209 209
 
210
-		foreach ( self::get_pages() as $key => $page ) {
211
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
210
+		foreach (self::get_pages() as $key => $page) {
211
+			wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']);
212 212
 		}
213 213
 
214 214
 	}
@@ -222,32 +222,32 @@  discard block
 block discarded – undo
222 222
 
223 223
 		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
224 224
 		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
225
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
225
+		$migrated            = $wpdb->get_col("SELECT post_id FROM $invoices_table");
226 226
 		$invoices            = array_unique(
227 227
 			get_posts(
228 228
 				array(
229
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
229
+					'post_type'      => array('wpi_invoice', 'wpi_quote'),
230 230
 					'posts_per_page' => -1,
231 231
 					'fields'         => 'ids',
232
-					'post_status'    => array_keys( get_post_stati() ),
232
+					'post_status'    => array_keys(get_post_stati()),
233 233
 					'exclude'        => (array) $migrated,
234 234
 				)
235 235
 			)
236 236
 		);
237 237
 
238 238
 		// Abort if we do not have any invoices.
239
-		if ( empty( $invoices ) ) {
239
+		if (empty($invoices)) {
240 240
 			return;
241 241
 		}
242 242
 
243 243
 		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
244 244
 
245 245
 		$invoice_rows = array();
246
-		foreach ( $invoices as $invoice ) {
246
+		foreach ($invoices as $invoice) {
247 247
 
248
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
248
+			$invoice = new WPInv_Legacy_Invoice($invoice);
249 249
 
250
-			if ( empty( $invoice->ID ) ) {
250
+			if (empty($invoice->ID)) {
251 251
 				return;
252 252
 			}
253 253
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 				'post_id'            => $invoice->ID,
256 256
 				'number'             => $invoice->get_number(),
257 257
 				'key'                => $invoice->get_key(),
258
-				'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
258
+				'type'               => str_replace('wpi_', '', $invoice->post_type),
259 259
 				'mode'               => $invoice->mode,
260 260
 				'user_ip'            => $invoice->get_ip(),
261 261
 				'first_name'         => $invoice->get_first_name(),
@@ -284,27 +284,27 @@  discard block
 block discarded – undo
284 284
 				'custom_meta'        => $invoice->payment_meta,
285 285
 			);
286 286
 
287
-			foreach ( $fields as $key => $val ) {
288
-				if ( is_null( $val ) ) {
287
+			foreach ($fields as $key => $val) {
288
+				if (is_null($val)) {
289 289
 					$val = '';
290 290
 				}
291
-				$val = maybe_serialize( $val );
292
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
291
+				$val = maybe_serialize($val);
292
+				$fields[$key] = $wpdb->prepare('%s', $val);
293 293
 			}
294 294
 
295
-			$fields = implode( ', ', $fields );
295
+			$fields = implode(', ', $fields);
296 296
 			$invoice_rows[] = "($fields)";
297 297
 
298 298
 			$item_rows    = array();
299 299
 			$item_columns = array();
300
-			foreach ( $invoice->get_cart_details() as $details ) {
300
+			foreach ($invoice->get_cart_details() as $details) {
301 301
 				$fields = array(
302 302
 					'post_id'          => $invoice->ID,
303 303
 					'item_id'          => $details['id'],
304 304
 					'item_name'        => $details['name'],
305
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
305
+					'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
306 306
 					'vat_rate'         => $details['vat_rate'],
307
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
307
+					'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
308 308
 					'tax'              => $details['tax'],
309 309
 					'item_price'       => $details['item_price'],
310 310
 					'custom_price'     => $details['custom_price'],
@@ -316,31 +316,31 @@  discard block
 block discarded – undo
316 316
 					'fees'             => $details['fees'],
317 317
 				);
318 318
 
319
-				$item_columns = array_keys( $fields );
319
+				$item_columns = array_keys($fields);
320 320
 
321
-				foreach ( $fields as $key => $val ) {
322
-					if ( is_null( $val ) ) {
321
+				foreach ($fields as $key => $val) {
322
+					if (is_null($val)) {
323 323
 						$val = '';
324 324
 					}
325
-					$val = maybe_serialize( $val );
326
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
325
+					$val = maybe_serialize($val);
326
+					$fields[$key] = $wpdb->prepare('%s', $val);
327 327
 				}
328 328
 
329
-				$fields = implode( ', ', $fields );
329
+				$fields = implode(', ', $fields);
330 330
 				$item_rows[] = "($fields)";
331 331
 			}
332 332
 
333
-			$item_rows    = implode( ', ', $item_rows );
334
-			$item_columns = implode( ', ', $item_columns );
335
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
333
+			$item_rows    = implode(', ', $item_rows);
334
+			$item_columns = implode(', ', $item_columns);
335
+			$wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
336 336
 		}
337 337
 
338
-		if ( empty( $invoice_rows ) ) {
338
+		if (empty($invoice_rows)) {
339 339
 			return;
340 340
 		}
341 341
 
342
-		$invoice_rows = implode( ', ', $invoice_rows );
343
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
342
+		$invoice_rows = implode(', ', $invoice_rows);
343
+		$wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
344 344
 
345 345
 	}
346 346
 
@@ -352,32 +352,32 @@  discard block
 block discarded – undo
352 352
 		global $wpdb;
353 353
 
354 354
 		// Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null.
355
-		$invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" );
355
+		$invoice_ids = $wpdb->get_col("SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL");
356 356
 
357
-		foreach ( $invoice_ids as $invoice_id ) {
358
-			$invoice = wpinv_get_invoice( $invoice_id );
357
+		foreach ($invoice_ids as $invoice_id) {
358
+			$invoice = wpinv_get_invoice($invoice_id);
359 359
 
360
-			if ( empty( $invoice ) ) {
360
+			if (empty($invoice)) {
361 361
 				continue;
362 362
 			}
363 363
 
364 364
 			// Fetch customer from the user ID.
365 365
 			$user_id = $invoice->get_user_id();
366 366
 
367
-			if ( empty( $user_id ) ) {
367
+			if (empty($user_id)) {
368 368
 				continue;
369 369
 			}
370 370
 
371
-			$customer = getpaid_get_customer_by_user_id( $user_id );
371
+			$customer = getpaid_get_customer_by_user_id($user_id);
372 372
 
373 373
 			// Create if not exists.
374
-			if ( empty( $customer ) ) {
375
-				$customer = new GetPaid_Customer( 0 );
376
-				$customer->clone_user( $user_id );
374
+			if (empty($customer)) {
375
+				$customer = new GetPaid_Customer(0);
376
+				$customer->clone_user($user_id);
377 377
 				$customer->save();
378 378
 			}
379 379
 
380
-			$invoice->set_customer_id( $customer->get_id() );
380
+			$invoice->set_customer_id($customer->get_id());
381 381
 			$invoice->save();
382 382
 		}
383 383
 
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 	public static function rename_gateways_label() {
391 391
 		global $wpdb;
392 392
 
393
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
393
+		foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) {
394 394
 
395 395
 			$wpdb->update(
396 396
 				$wpdb->prefix . 'getpaid_invoices',
397
-				array( 'gateway' => $gateway ),
398
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
397
+				array('gateway' => $gateway),
398
+				array('gateway' => wpinv_get_gateway_admin_label($gateway)),
399 399
 				'%s',
400 400
 				'%s'
401 401
 			);
@@ -511,29 +511,29 @@  discard block
 block discarded – undo
511 511
 			";
512 512
 
513 513
 		// Add address fields.
514
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
514
+		foreach (array_keys(getpaid_user_address_fields()) as $field) {
515 515
 			// Skip id, user_id and email.
516
-			if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
516
+			if (in_array($field, array('id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid'), true)) {
517 517
 				continue;
518 518
 			}
519 519
 
520
-			$field   = sanitize_key( $field );
520
+			$field   = sanitize_key($field);
521 521
 			$length  = 100;
522 522
 			$default = '';
523 523
 
524 524
 			// Country.
525
-			if ( 'country' === $field ) {
525
+			if ('country' === $field) {
526 526
 				$length  = 2;
527 527
 				$default = wpinv_get_default_country();
528 528
 			}
529 529
 
530 530
 			// State.
531
-			if ( 'state' === $field ) {
531
+			if ('state' === $field) {
532 532
 				$default = wpinv_get_default_state();
533 533
 			}
534 534
 
535 535
 			// Phone, zip.
536
-			if ( in_array( $field, array( 'phone', 'zip' ), true ) ) {
536
+			if (in_array($field, array('phone', 'zip'), true)) {
537 537
 				$length = 20;
538 538
 			}
539 539
 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 	 * @return bool
570 570
 	 */
571 571
 	public static function is_db_schema_up_to_date() {
572
-		return md5( self::get_db_schema() ) === get_option( 'getpaid_db_schema' );
572
+		return md5(self::get_db_schema()) === get_option('getpaid_db_schema');
573 573
 	}
574 574
 
575 575
 	/**
@@ -587,27 +587,27 @@  discard block
 block discarded – undo
587 587
 		// If invoices table exists, rename key to invoice_key.
588 588
 		$invoices_table = "{$wpdb->prefix}getpaid_invoices";
589 589
 
590
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) === $invoices_table ) {
591
-			$fields = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices" );
590
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") === $invoices_table) {
591
+			$fields = $wpdb->get_results("SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices");
592 592
 
593
-			foreach ( $fields as $field ) {
594
-				if ( 'key' === $field->Field ) {
595
-					$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)" );
593
+			foreach ($fields as $field) {
594
+				if ('key' === $field->Field) {
595
+					$wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)");
596 596
 					break;
597 597
 				}
598 598
 			}
599 599
 		}
600 600
 
601
-		dbDelta( $schema );
601
+		dbDelta($schema);
602 602
 		wp_cache_flush();
603
-		update_option( 'getpaid_db_schema', md5( $schema ) );
603
+		update_option('getpaid_db_schema', md5($schema));
604 604
 	}
605 605
 
606 606
 	/**
607 607
 	 * Creates tables if schema is not up to date.
608 608
 	 */
609 609
 	public static function maybe_create_db_tables() {
610
-		if ( ! self::is_db_schema_up_to_date() ) {
610
+		if (!self::is_db_schema_up_to_date()) {
611 611
 			self::create_db_tables();
612 612
 		}
613 613
 	}
Please login to merge, or discard this patch.
includes/admin/class-wpinv-customers-table.php 1 patch
Spacing   +61 added lines, -61 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
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return string Column Name
80 80
 	 */
81
-	public function column_default( $customer, $column_name ) {
82
-		$value = esc_html( $customer->get( $column_name ) );
83
-		return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $customer );
81
+	public function column_default($customer, $column_name) {
82
+		$value = esc_html($customer->get($column_name));
83
+		return apply_filters('wpinv_customers_table_column' . $column_name, $value, $customer);
84 84
 	}
85 85
 
86 86
 	/**
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return string Column Name
94 94
 	 */
95
-	public function column_country( $customer ) {
96
-		$country = wpinv_sanitize_country( $customer->get( 'country' ) );
97
-		if ( $country ) {
98
-			$country = wpinv_country_name( $country );
95
+	public function column_country($customer) {
96
+		$country = wpinv_sanitize_country($customer->get('country'));
97
+		if ($country) {
98
+			$country = wpinv_country_name($country);
99 99
 		}
100
-		return esc_html( $country );
100
+		return esc_html($country);
101 101
 	}
102 102
 
103 103
 	/**
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return string Column Name
111 111
 	 */
112
-	public function column_state( $customer ) {
113
-		$country = wpinv_sanitize_country( $customer->get( 'country' ) );
114
-		$state   = $customer->get( 'state' );
115
-		if ( $state ) {
116
-			$state = wpinv_state_name( $state, $country );
112
+	public function column_state($customer) {
113
+		$country = wpinv_sanitize_country($customer->get('country'));
114
+		$state   = $customer->get('state');
115
+		if ($state) {
116
+			$state = wpinv_state_name($state, $country);
117 117
 		}
118 118
 
119
-		return esc_html( $state );
119
+		return esc_html($state);
120 120
 	}
121 121
 
122 122
 	/**
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return string Column Name
130 130
 	 */
131
-	public function column_date_created( $customer ) {
132
-		return getpaid_format_date_value( $customer->get( 'date_created' ) );
131
+	public function column_date_created($customer) {
132
+		return getpaid_format_date_value($customer->get('date_created'));
133 133
 	}
134 134
 
135 135
 	/**
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @return string Column Name
143 143
 	 */
144
-	public function column_purchase_value( $customer ) {
145
-		return wpinv_price( (float) $customer->get( 'purchase_value' ) );
144
+	public function column_purchase_value($customer) {
145
+		return wpinv_price((float) $customer->get('purchase_value'));
146 146
 	}
147 147
 
148 148
 	/**
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @return string Column Name
156 156
 	 */
157
-	public function column_purchase_count( $customer ) {
158
-		$value = $customer->get( 'purchase_count' );
159
-		$url   = $customer->get( 'user_id' ) ? add_query_arg( array( 'post_type' => 'wpi_invoice', 'author' => $customer->get( 'user_id' ), ), admin_url( 'edit.php' ) ) : '';
157
+	public function column_purchase_count($customer) {
158
+		$value = $customer->get('purchase_count');
159
+		$url   = $customer->get('user_id') ? add_query_arg(array('post_type' => 'wpi_invoice', 'author' => $customer->get('user_id'),), admin_url('edit.php')) : '';
160 160
 
161
-		return ( empty( $value ) || empty( $url ) ) ? (int) $value : '<a href="' . esc_url( $url ) . '">' . absint( $value ) . '</a>';
161
+		return (empty($value) || empty($url)) ? (int) $value : '<a href="' . esc_url($url) . '">' . absint($value) . '</a>';
162 162
 
163 163
 	}
164 164
 
@@ -168,25 +168,25 @@  discard block
 block discarded – undo
168 168
 	 * @param  GetPaid_Customer $customer customer.
169 169
 	 * @return string
170 170
 	 */
171
-	public function column_customer( $customer ) {
171
+	public function column_customer($customer) {
172 172
 
173
-		$first_name = $customer->get( 'first_name' );
174
-		$last_name  = $customer->get( 'last_name' );
175
-		$email      = $customer->get( 'email' );
176
-		$avatar     = get_avatar( $customer->get( 'user_id' ) ? $customer->get( 'user_id' ) : $email, 32 );
173
+		$first_name = $customer->get('first_name');
174
+		$last_name  = $customer->get('last_name');
175
+		$email      = $customer->get('email');
176
+		$avatar     = get_avatar($customer->get('user_id') ? $customer->get('user_id') : $email, 32);
177 177
 
178 178
 		// Customer view URL.
179
-		$view_url    = $customer->get( 'user_id' ) ? esc_url( add_query_arg( 'user_id', $customer->get( 'user_id' ), admin_url( 'user-edit.php' ) ) ) : false;
179
+		$view_url    = $customer->get('user_id') ? esc_url(add_query_arg('user_id', $customer->get('user_id'), admin_url('user-edit.php'))) : false;
180 180
 		$row_actions = $view_url ? $this->row_actions(
181 181
 			array(
182
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
182
+				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>',
183 183
 			)
184 184
 		) : '';
185 185
 
186 186
 		// Customer's name.
187
-		$name   = esc_html( trim( "$first_name $last_name" ) );
187
+		$name = esc_html(trim("$first_name $last_name"));
188 188
 
189
-		if ( ! empty( $name ) ) {
189
+		if (!empty($name)) {
190 190
 			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
191 191
 		}
192 192
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @return int Current page number
204 204
 	 */
205 205
 	public function get_paged() {
206
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
206
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @since 1.0.19
213 213
 	 * @return void
214 214
 	 */
215
-	public function bulk_actions( $which = '' ) {
215
+	public function bulk_actions($which = '') {
216 216
 		return array();
217 217
 	}
218 218
 
@@ -227,33 +227,33 @@  discard block
 block discarded – undo
227 227
 			'paged'  => $this->get_paged(),
228 228
 		);
229 229
 
230
-		foreach ( array( 'orderby', 'order', 's' ) as $field ) {
231
-			if ( isset( $_GET[ $field ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
232
-				$query[ $field ] = wpinv_clean( rawurlencode_deep( $_GET[ $field ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
230
+		foreach (array('orderby', 'order', 's') as $field) {
231
+			if (isset($_GET[$field])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
232
+				$query[$field] = wpinv_clean(rawurlencode_deep($_GET[$field])); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
233 233
 			}
234 234
 		}
235 235
 
236
-		foreach ( GetPaid_Customer_Data_Store::get_database_fields() as $field => $type ) {
236
+		foreach (GetPaid_Customer_Data_Store::get_database_fields() as $field => $type) {
237 237
 
238
-			if ( isset( $_GET[ $field ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
239
-				$query[ $field ] = wpinv_clean( rawurlencode_deep( $_GET[ $field ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
238
+			if (isset($_GET[$field])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
239
+				$query[$field] = wpinv_clean(rawurlencode_deep($_GET[$field])); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
240 240
 			}
241 241
 
242 242
 			// Min max.
243
-			if ( '%f' === $type || '%d' === $type ) {
243
+			if ('%f' === $type || '%d' === $type) {
244 244
 
245
-				if ( isset( $_GET[ $field . '_min' ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
246
-					$query[ $field . '_min' ] = floatval( $_GET[ $field . '_min' ] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
245
+				if (isset($_GET[$field . '_min'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
246
+					$query[$field . '_min'] = floatval($_GET[$field . '_min']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
247 247
 				}
248 248
 
249
-				if ( isset( $_GET[ $field . '_max' ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
250
-					$query[ $field . '_max' ] = floatval( $_GET[ $field . '_max' ] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
249
+				if (isset($_GET[$field . '_max'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
250
+					$query[$field . '_max'] = floatval($_GET[$field . '_max']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
251 251
 				}
252 252
 			}
253 253
 		}
254 254
 
255 255
 		// Prepare class properties.
256
-		$this->query       = getpaid_get_customers( $query, 'query' );
256
+		$this->query       = getpaid_get_customers($query, 'query');
257 257
 		$this->total_count = $this->query->get_total();
258 258
 		$this->items       = $this->query->get_results();
259 259
 	}
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
 		$sortable = $this->get_sortable_columns();
270 270
 		$this->prepare_query();
271 271
 
272
-		$this->_column_headers = array( $columns, $hidden, $sortable );
272
+		$this->_column_headers = array($columns, $hidden, $sortable);
273 273
 
274 274
 		$this->set_pagination_args(
275 275
 			array(
276 276
 				'total_items' => $this->total_count,
277 277
 				'per_page'    => $this->per_page,
278
-				'total_pages' => ceil( $this->total_count / $this->per_page ),
278
+				'total_pages' => ceil($this->total_count / $this->per_page),
279 279
 			)
280 280
 		);
281 281
 	}
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
 	 */
288 288
 	public function get_sortable_columns() {
289 289
 		$sortable = array(
290
-			'customer' => array( 'first_name', true ),
290
+			'customer' => array('first_name', true),
291 291
 		);
292 292
 
293
-		foreach ( GetPaid_Customer_Data_Store::get_database_fields() as $field => $type ) {
294
-			$sortable[ $field ] = array( $field, true );
293
+		foreach (GetPaid_Customer_Data_Store::get_database_fields() as $field => $type) {
294
+			$sortable[$field] = array($field, true);
295 295
 		}
296 296
 
297
-		return apply_filters( 'manage_getpaid_customers_sortable_table_columns', $sortable );
297
+		return apply_filters('manage_getpaid_customers_sortable_table_columns', $sortable);
298 298
 	}
299 299
 
300 300
 	/**
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 	 */
305 305
 	public function get_columns() {
306 306
 		$columns = array(
307
-			'customer' => __( 'Customer', 'invoicing' ),
307
+			'customer' => __('Customer', 'invoicing'),
308 308
 		);
309 309
 
310 310
 		// Add address fields.
311
-		foreach ( getpaid_user_address_fields() as $key => $value ) {
311
+		foreach (getpaid_user_address_fields() as $key => $value) {
312 312
 
313 313
 			// Skip id, user_id and email.
314
-			if ( ! in_array( $key, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid', 'first_name', 'last_name' ), true ) ) {
315
-				$columns[ $key ] = $value;
314
+			if (!in_array($key, array('id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid', 'first_name', 'last_name'), true)) {
315
+				$columns[$key] = $value;
316 316
 			}
317 317
 		}
318 318
 
319
-		$columns['purchase_value'] = __( 'Total Spend', 'invoicing' );
320
-		$columns['purchase_count'] = __( 'Invoices', 'invoicing' );
321
-		$columns['date_created']   = __( 'Date created', 'invoicing' );
319
+		$columns['purchase_value'] = __('Total Spend', 'invoicing');
320
+		$columns['purchase_count'] = __('Invoices', 'invoicing');
321
+		$columns['date_created']   = __('Date created', 'invoicing');
322 322
 
323
-		return apply_filters( 'manage_getpaid_customers_table_columns', $columns );
323
+		return apply_filters('manage_getpaid_customers_table_columns', $columns);
324 324
 	}
325 325
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) );
17
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
18
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
19
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
20
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
21
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
22
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
23
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_head', array($this, 'set_admin_menu_class'));
17
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
18
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
19
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
20
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
21
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
22
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
23
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
24 24
     }
25 25
 
26 26
     /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function set_admin_menu_class() {
30 30
 		global $current_screen, $parent_file, $submenu_file;
31 31
 
32
-        if ( ! empty( $current_screen->id ) && in_array( $current_screen->id, array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) {
32
+        if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) {
33 33
 			$parent_file = 'wpinv';
34 34
 			$submenu_file = 'edit.php?post_type=' . $current_screen->id;
35 35
         }
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function admin_menu() {
40 40
 
41
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
41
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
42 42
         add_menu_page(
43
-            __( 'GetPaid', 'invoicing' ),
44
-            __( 'GetPaid', 'invoicing' ),
43
+            __('GetPaid', 'invoicing'),
44
+            __('GetPaid', 'invoicing'),
45 45
             $capability,
46 46
             'wpinv',
47 47
             null,
48
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
48
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
49 49
             '54.123460'
50 50
         );
51 51
 
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
     public function add_customers_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Customers', 'invoicing' ),
61
-            __( 'Customers', 'invoicing' ),
60
+            __('Customers', 'invoicing'),
61
+            __('Customers', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-customers',
64
-            array( $this, 'customers_page' )
64
+            array($this, 'customers_page')
65 65
         );
66 66
     }
67 67
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
     public function add_subscriptions_menu() {
72 72
         add_submenu_page(
73 73
             'wpinv',
74
-            __( 'Subscriptions', 'invoicing' ),
75
-            __( 'Subscriptions', 'invoicing' ),
74
+            __('Subscriptions', 'invoicing'),
75
+            __('Subscriptions', 'invoicing'),
76 76
             wpinv_get_capability(),
77 77
             'wpinv-subscriptions',
78 78
             'wpinv_subscriptions_page'
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
                     width: 120px;
95 95
                 }
96 96
             </style>
97
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?>&nbsp;<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Export', 'invoicing' ); ?></a></h1>
98
-            <form method="get" style="overflow: auto; width: 100%" action=<?php echo esc_url( add_query_arg( array() ) ); ?>>
97
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?>&nbsp;<a href="<?php echo esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce')); ?>" class="page-title-action"><?php esc_html_e('Export', 'invoicing'); ?></a></h1>
98
+            <form method="get" style="overflow: auto; width: 100%" action=<?php echo esc_url(add_query_arg(array())); ?>>
99 99
                 <input type="hidden" name="page" value="wpinv-customers" />
100 100
                 <?php
101 101
                     $table = new WPInv_Customers_Table();
102 102
                     $table->prepare_items();
103
-                    $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
103
+                    $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
104 104
                     $table->display();
105 105
                 ?>
106 106
             </form>
@@ -114,26 +114,26 @@  discard block
 block discarded – undo
114 114
     public function add_settings_menu() {
115 115
         add_submenu_page(
116 116
             'wpinv',
117
-            __( 'Invoice Settings', 'invoicing' ),
118
-            __( 'Settings', 'invoicing' ),
119
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
117
+            __('Invoice Settings', 'invoicing'),
118
+            __('Settings', 'invoicing'),
119
+            apply_filters('invoicing_capability', wpinv_get_capability()),
120 120
             'wpinv-settings',
121
-            array( $this, 'options_page' )
121
+            array($this, 'options_page')
122 122
         );
123 123
     }
124 124
 
125 125
     public function add_addons_menu() {
126
-        if ( ! apply_filters( 'wpi_show_addons_page', true ) ) {
126
+        if (!apply_filters('wpi_show_addons_page', true)) {
127 127
             return;
128 128
         }
129 129
 
130 130
         add_submenu_page(
131 131
             'wpinv',
132
-            __( 'Invoicing extensions', 'invoicing' ),
133
-            __( 'Extensions', 'invoicing' ),
132
+            __('Invoicing extensions', 'invoicing'),
133
+            __('Extensions', 'invoicing'),
134 134
             'manage_options',
135 135
             'wpi-addons',
136
-            array( $this, 'addons_page' )
136
+            array($this, 'addons_page')
137 137
         );
138 138
     }
139 139
 
@@ -144,29 +144,29 @@  discard block
 block discarded – undo
144 144
 
145 145
     function options_page() {
146 146
 
147
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
147
+        if (!wpinv_current_user_can_manage_invoicing()) {
148 148
             return;
149 149
         }
150 150
 
151 151
         $settings_tabs = wpinv_get_settings_tabs();
152
-        $settings_tabs = empty( $settings_tabs ) ? array() : $settings_tabs;
153
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
154
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
152
+        $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
153
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
154
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
155 155
         $key           = 'main';
156 156
 
157
-        if ( is_array( $sections ) ) {
158
-            $key = key( $sections );
157
+        if (is_array($sections)) {
158
+            $key = key($sections);
159 159
         }
160 160
 
161 161
         add_thickbox();
162 162
 
163
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
164
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? sanitize_text_field( $_GET['section'] ) : $key;
163
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
164
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? sanitize_text_field($_GET['section']) : $key;
165 165
         ?>
166 166
         <div class="wrap">
167 167
             <h1 class="nav-tab-wrapper">
168 168
                 <?php
169
-                foreach ( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
169
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
170 170
                     $tab_url = add_query_arg(
171 171
                         array(
172 172
 							'settings-updated' => false,
@@ -176,23 +176,23 @@  discard block
 block discarded – undo
176 176
                     );
177 177
 
178 178
                     // Remove the section from the tabs so we always end up at the main section
179
-                    $tab_url = remove_query_arg( 'section', $tab_url );
180
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
179
+                    $tab_url = remove_query_arg('section', $tab_url);
180
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
181 181
 
182 182
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
183 183
 
184
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . esc_attr( $active ) . '">';
185
-                    echo esc_html( $tab_name );
184
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . esc_attr($active) . '">';
185
+                    echo esc_html($tab_name);
186 186
                     echo '</a>';
187 187
                 }
188 188
                 ?>
189 189
             </h1>
190 190
             <?php
191
-            $number_of_sections = count( $sections );
191
+            $number_of_sections = count($sections);
192 192
             $number = 0;
193
-            if ( $number_of_sections > 1 ) {
193
+            if ($number_of_sections > 1) {
194 194
                 echo '<div><ul class="subsubsub">';
195
-                foreach ( $sections as $section_id => $section_name ) {
195
+                foreach ($sections as $section_id => $section_name) {
196 196
                     echo '<li>';
197 197
                     $number++;
198 198
                     $tab_url = add_query_arg(
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 							'tab'              => $active_tab,
202 202
 							'section'          => $section_id,
203 203
                         ),
204
-                        admin_url( 'admin.php?page=wpinv-settings' )
204
+                        admin_url('admin.php?page=wpinv-settings')
205 205
                     );
206
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
206
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
207 207
                     $class = '';
208
-                    if ( $section == $section_id ) {
208
+                    if ($section == $section_id) {
209 209
                         $class = 'current';
210 210
                     }
211
-                    echo '<a class="' . esc_attr( $class ) . '" href="' . esc_url( $tab_url ) . '">' . esc_html( $section_name ) . '</a>';
211
+                    echo '<a class="' . esc_attr($class) . '" href="' . esc_url($tab_url) . '">' . esc_html($section_name) . '</a>';
212 212
 
213
-                    if ( $number != $number_of_sections ) {
213
+                    if ($number != $number_of_sections) {
214 214
                         echo ' | ';
215 215
                     }
216 216
                     echo '</li>';
@@ -222,20 +222,20 @@  discard block
 block discarded – undo
222 222
                 <form method="post" action="options.php">
223 223
                     <table class="form-table">
224 224
                         <?php
225
-                        settings_fields( 'wpinv_settings' );
225
+                        settings_fields('wpinv_settings');
226 226
 
227
-                        if ( 'main' === $section ) {
228
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
227
+                        if ('main' === $section) {
228
+                            do_action('wpinv_settings_tab_top', $active_tab);
229 229
                         }
230 230
 
231
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
232
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
233
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
234
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
231
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
232
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
233
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
234
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
235 235
 
236 236
                         // For backwards compatibility
237
-                        if ( 'main' === $section ) {
238
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
237
+                        if ('main' === $section) {
238
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
239 239
                         }
240 240
                         ?>
241 241
                     </table>
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
     }
248 248
 
249 249
     public function remove_admin_submenus() {
250
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
250
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
251 251
     }
252 252
 
253 253
     /**
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 
258 258
         add_meta_box(
259 259
             'wpinv_endpoints_nav_link',
260
-            __( 'GetPaid endpoints', 'invoicing' ),
261
-            array( $this, 'nav_menu_links' ),
260
+            __('GetPaid endpoints', 'invoicing'),
261
+            array($this, 'nav_menu_links'),
262 262
             'nav-menus',
263 263
             'side',
264 264
             'low'
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
         $endpoints = $this->get_menu_items();
274 274
         ?>
275 275
         <div id="invoicing-endpoints" class="posttypediv">
276
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
276
+            <?php if (!empty($endpoints['pages'])) : ?>
277 277
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
278 278
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
279 279
                         <?php
280
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
281
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
280
+                            $walker = new Walker_Nav_Menu_Checklist(array());
281
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
282 282
                         ?>
283 283
                     </ul>
284 284
                 </div>
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
288 288
                 <span class="list-controls hide-if-no-js">
289 289
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
290
-                    <label for="invoicing-endpoints-tab"><?php esc_html_e( 'Select all', 'invoicing' ); ?></label>
290
+                    <label for="invoicing-endpoints-tab"><?php esc_html_e('Select all', 'invoicing'); ?></label>
291 291
                 </span>
292 292
 
293 293
                 <span class="add-to-menu">
294
-                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
294
+                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
295 295
                     <span class="spinner"></span>
296 296
                 </span>
297 297
             </p>
@@ -309,18 +309,18 @@  discard block
 block discarded – undo
309 309
 
310 310
         $pages = array(
311 311
             array(
312
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
313
-                'label' => __( 'My Invoices', 'invoicing' ),
312
+                'id'    => wpinv_get_option('invoice_history_page'),
313
+                'label' => __('My Invoices', 'invoicing'),
314 314
             ),
315 315
             array(
316
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
317
-                'label' => __( 'My Subscriptions', 'invoicing' ),
316
+                'id'    => wpinv_get_option('invoice_subscription_page'),
317
+                'label' => __('My Subscriptions', 'invoicing'),
318 318
             ),
319 319
         );
320 320
 
321
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
321
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
322 322
 
323
-            if ( (int) $page['id'] > 0 ) {
323
+            if ((int) $page['id'] > 0) {
324 324
 
325 325
                 $item                   = new stdClass();
326 326
                 $item->object_id        = (int) $page['id'];
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
                 $item->object           = 'page';
329 329
                 $item->menu_item_parent = 0;
330 330
                 $item->type             = 'post_type';
331
-                $item->title            = esc_html( $page['label'] );
332
-                $item->url              = get_permalink( (int) $page['id'] );
331
+                $item->title            = esc_html($page['label']);
332
+                $item->url              = get_permalink((int) $page['id']);
333 333
                 $item->target           = '';
334 334
                 $item->attr_title       = '';
335
-                $item->classes          = array( 'wpinv-menu-item' );
335
+                $item->classes          = array('wpinv-menu-item');
336 336
                 $item->xfn              = '';
337 337
 
338 338
                 $items['pages'][]       = $item;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
             }
341 341
 }
342 342
 
343
-        return apply_filters( 'wpinv_menu_items', $items );
343
+        return apply_filters('wpinv_menu_items', $items);
344 344
     }
345 345
 
346 346
 }
Please login to merge, or discard this patch.