Test Failed
Push — master ( 95d83a...9f58db )
by Devin
11:53 queued 05:36
created
includes/admin/payments/class-payments-table.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 	/**
529 529
 	 * Get donor email html.
530 530
 	 *
531
-	 * @param object $payment Contains all the data of the payment.
531
+	 * @param Give_Payment $payment Contains all the data of the payment.
532 532
 	 *
533 533
 	 * @access public
534 534
 	 * @since  1.0
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 	/**
557 557
 	 * Get Row Actions
558 558
 	 *
559
-	 * @param object $payment Payment Data.
559
+	 * @param Give_Payment $payment Payment Data.
560 560
 	 *
561 561
 	 * @since 1.6
562 562
 	 *
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 	/**
678 678
 	 * Get donor html.
679 679
 	 *
680
-	 * @param object $payment Contains all the data of the payment.
680
+	 * @param Give_Payment $payment Contains all the data of the payment.
681 681
 	 *
682 682
 	 * @access public
683 683
 	 * @since  1.0
Please login to merge, or discard this patch.
Spacing   +219 added lines, -220 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded.
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 		// Set parent defaults.
137 137
 		parent::__construct(
138 138
 			array(
139
-				'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
140
-				'plural'   => give_get_forms_label_plural(),      // Plural name of the listed records.
141
-				'ajax'     => false,                              // Does this table support ajax?
139
+				'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
140
+				'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
141
+				'ajax'     => false, // Does this table support ajax?
142 142
 			)
143 143
 		);
144 144
 
145 145
 		$this->process_bulk_action();
146 146
 		$this->get_payment_counts();
147
-		$this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' );
147
+		$this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history');
148 148
 	}
149 149
 
150 150
 	/**
@@ -153,32 +153,32 @@  discard block
 block discarded – undo
153 153
 	 * @return void
154 154
 	 */
155 155
 	public function advanced_filters() {
156
-		$start_date = isset( $_GET['start-date'] ) ? give_clean( $_GET['start-date'] ) : null;
157
-		$end_date   = isset( $_GET['end-date'] ) ? give_clean( $_GET['end-date'] ) : null;
158
-		$status     = isset( $_GET['status'] ) ? give_clean( $_GET['status'] ) : '';
159
-		$donor      = isset( $_GET['donor'] ) ? absint( $_GET['donor'] ) : '';
160
-		$search     = isset( $_GET['s'] ) ? give_clean( $_GET['s'] ) : '';
161
-		$form_id    = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0;
156
+		$start_date = isset($_GET['start-date']) ? give_clean($_GET['start-date']) : null;
157
+		$end_date   = isset($_GET['end-date']) ? give_clean($_GET['end-date']) : null;
158
+		$status     = isset($_GET['status']) ? give_clean($_GET['status']) : '';
159
+		$donor      = isset($_GET['donor']) ? absint($_GET['donor']) : '';
160
+		$search     = isset($_GET['s']) ? give_clean($_GET['s']) : '';
161
+		$form_id    = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : 0;
162 162
 		$localized_date_format = give_get_localized_date_format_to_js();
163 163
 		?>
164 164
 		<div id="give-payment-filters" class="give-filters">
165
-			<?php $this->search_box( __( 'Search', 'give' ), 'give-payments' ); ?>
165
+			<?php $this->search_box(__('Search', 'give'), 'give-payments'); ?>
166 166
 			<div id="give-payment-date-filters">
167 167
 				<div class="give-filter give-filter-half">
168 168
 					<label for="start-date"
169
-					       class="give-start-date-label"><?php _e( 'Start Date', 'give' ); ?></label>
169
+					       class="give-start-date-label"><?php _e('Start Date', 'give'); ?></label>
170 170
 					<input type="text" id="start-date" name="start-date" class="give_datepicker"
171
-					       value="<?php printf( esc_attr( $start_date ) ); ?>" placeholder="<?php printf( esc_attr( $localized_date_format ) ); ?>"/>
171
+					       value="<?php printf(esc_attr($start_date)); ?>" placeholder="<?php printf(esc_attr($localized_date_format)); ?>"/>
172 172
 				</div>
173 173
 				<div class="give-filter give-filter-half">
174
-					<label for="end-date" class="give-end-date-label"><?php _e( 'End Date', 'give' ); ?></label>
174
+					<label for="end-date" class="give-end-date-label"><?php _e('End Date', 'give'); ?></label>
175 175
 					<input type="text" id="end-date" name="end-date" class="give_datepicker"
176
-					       value="<?php printf( esc_attr( $end_date ) ); ?>" placeholder="<?php printf( esc_attr( $localized_date_format ) ); ?>"/>
176
+					       value="<?php printf(esc_attr($end_date)); ?>" placeholder="<?php printf(esc_attr($localized_date_format)); ?>"/>
177 177
 				</div>
178 178
 			</div>
179 179
 			<div id="give-payment-form-filter" class="give-filter">
180 180
 				<label for="give-donation-forms-filter"
181
-				       class="give-donation-forms-filter-label"><?php _e( 'Form', 'give' ); ?></label>
181
+				       class="give-donation-forms-filter-label"><?php _e('Form', 'give'); ?></label>
182 182
 				<?php
183 183
 				// Filter Donations by Donation Forms.
184 184
 				echo Give()->html->forms_dropdown(
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 						'class'    => 'give-donation-forms-filter',
189 189
 						'selected' => $form_id, // Make sure to have $form_id set to 0, if there is no selection.
190 190
 						'chosen'   => true,
191
-						'number'   => - 1,
191
+						'number'   => -1,
192 192
 					)
193 193
 				);
194 194
 				?>
@@ -200,26 +200,26 @@  discard block
 block discarded – undo
200 200
 			 *
201 201
 			 * @since 1.8.18
202 202
 			 */
203
-			do_action( 'give_payment_table_advanced_filters' );
203
+			do_action('give_payment_table_advanced_filters');
204 204
 
205 205
 
206
-			if ( ! empty( $status ) ) {
207
-				echo sprintf( '<input type="hidden" name="status" value="%s"/>', esc_attr( $status ) );
206
+			if ( ! empty($status)) {
207
+				echo sprintf('<input type="hidden" name="status" value="%s"/>', esc_attr($status));
208 208
 			}
209 209
 
210
-			if ( ! empty( $donor ) ) {
211
-				echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $donor ) );
210
+			if ( ! empty($donor)) {
211
+				echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($donor));
212 212
 			}
213 213
 			?>
214 214
 
215 215
 			<div class="give-filter">
216
-				<?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?>
216
+				<?php submit_button(__('Apply', 'give'), 'secondary', '', false); ?>
217 217
 				<?php
218 218
 				// Clear active filters button.
219
-				if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $donor ) || ! empty( $search ) || ! empty( $status ) || ! empty( $form_id ) ) :
219
+				if ( ! empty($start_date) || ! empty($end_date) || ! empty($donor) || ! empty($search) || ! empty($status) || ! empty($form_id)) :
220 220
 					?>
221
-					<a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"
222
-					   class="button give-clear-filters-button"><?php _e( 'Clear Filters', 'give' ); ?></a>
221
+					<a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"
222
+					   class="button give-clear-filters-button"><?php _e('Clear Filters', 'give'); ?></a>
223 223
 				<?php endif; ?>
224 224
 			</div>
225 225
 		</div>
@@ -238,18 +238,18 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return void
240 240
 	 */
241
-	public function search_box( $text, $input_id ) {
242
-		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
241
+	public function search_box($text, $input_id) {
242
+		if (empty($_REQUEST['s']) && ! $this->has_items()) {
243 243
 			return;
244 244
 		}
245 245
 
246
-		$input_id = $input_id . '-search-input';
246
+		$input_id = $input_id.'-search-input';
247 247
 
248
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
249
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
248
+		if ( ! empty($_REQUEST['orderby'])) {
249
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
250 250
 		}
251
-		if ( ! empty( $_REQUEST['order'] ) ) {
252
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
251
+		if ( ! empty($_REQUEST['order'])) {
252
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
253 253
 		}
254 254
 		?>
255 255
 		<div class="give-filter give-filter-search" role="search">
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
 			 *
262 262
 			 * @since 1.7
263 263
 			 */
264
-			do_action( 'give_payment_history_search' );
264
+			do_action('give_payment_history_search');
265 265
 			?>
266 266
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
267 267
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
268
-			<?php submit_button( $text, 'button', false, false, array(
268
+			<?php submit_button($text, 'button', false, false, array(
269 269
 				'ID' => 'search-submit',
270
-			) ); ?><br/>
270
+			)); ?><br/>
271 271
 		</div>
272 272
 		<?php
273 273
 	}
@@ -282,48 +282,48 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	public function get_views() {
284 284
 
285
-		$current = isset( $_GET['status'] ) ? $_GET['status'] : '';
285
+		$current = isset($_GET['status']) ? $_GET['status'] : '';
286 286
 		$views   = array();
287 287
 		$tabs    = array(
288 288
 			'all'         => array(
289 289
 				'total_count',
290
-				__( 'All', 'give' ),
290
+				__('All', 'give'),
291 291
 			),
292 292
 			'publish'     => array(
293 293
 				'complete_count',
294
-				__( 'Completed', 'give' ),
294
+				__('Completed', 'give'),
295 295
 			),
296 296
 			'pending'     => array(
297 297
 				'pending_count',
298
-				__( 'Pending', 'give' ),
298
+				__('Pending', 'give'),
299 299
 			),
300 300
 			'processing'  => array(
301 301
 				'processing_count',
302
-				__( 'Processing', 'give' ),
302
+				__('Processing', 'give'),
303 303
 			),
304 304
 			'refunded'    => array(
305 305
 				'refunded_count',
306
-				__( 'Refunded', 'give' ),
306
+				__('Refunded', 'give'),
307 307
 			),
308 308
 			'revoked'     => array(
309 309
 				'revoked_count',
310
-				__( 'Revoked', 'give' ),
310
+				__('Revoked', 'give'),
311 311
 			),
312 312
 			'failed'      => array(
313 313
 				'failed_count',
314
-				__( 'Failed', 'give' ),
314
+				__('Failed', 'give'),
315 315
 			),
316 316
 			'cancelled'   => array(
317 317
 				'cancelled_count',
318
-				__( 'Cancelled', 'give' ),
318
+				__('Cancelled', 'give'),
319 319
 			),
320 320
 			'abandoned'   => array(
321 321
 				'abandoned_count',
322
-				__( 'Abandoned', 'give' ),
322
+				__('Abandoned', 'give'),
323 323
 			),
324 324
 			'preapproval' => array(
325 325
 				'preapproval_count',
326
-				__( 'Preapproval Pending', 'give' ),
326
+				__('Preapproval Pending', 'give'),
327 327
 			),
328 328
 		);
329 329
 
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 		 *
333 333
 		 * @since 1.8.18
334 334
 		 */
335
-		$args = (array) apply_filters( 'give_payments_table_status_remove_query_arg', array( 'paged', '_wpnonce', '_wp_http_referer' ) );
335
+		$args = (array) apply_filters('give_payments_table_status_remove_query_arg', array('paged', '_wpnonce', '_wp_http_referer'));
336 336
 
337 337
 		// Build URL.
338
-		$staus_url = remove_query_arg( $args );
338
+		$staus_url = remove_query_arg($args);
339 339
 
340
-		foreach ( $tabs as $key => $tab ) {
340
+		foreach ($tabs as $key => $tab) {
341 341
 			$count_key = $tab[0];
342 342
 			$name      = $tab[1];
343 343
 			$count     = $this->$count_key;
@@ -352,16 +352,15 @@  discard block
 block discarded – undo
352 352
 			 *
353 353
 			 * @since 1.8.12
354 354
 			 */
355
-			if ( 'all' === $key || $key === $current || apply_filters( 'give_payments_table_show_all_status', 0 < $count, $key, $count ) ) {
355
+			if ('all' === $key || $key === $current || apply_filters('give_payments_table_show_all_status', 0 < $count, $key, $count)) {
356 356
 
357 357
 				$staus_url = 'all' === $key ?
358
-					add_query_arg( array( 'status' => false ), $staus_url ) :
359
-					add_query_arg( array( 'status' => $key ), $staus_url );
358
+					add_query_arg(array('status' => false), $staus_url) : add_query_arg(array('status' => $key), $staus_url);
360 359
 
361
-				$views[ $key ] = sprintf(
360
+				$views[$key] = sprintf(
362 361
 					'<a href="%s"%s>%s&nbsp;<span class="count">(%s)</span></a>',
363
-					esc_url( $staus_url ),
364
-					( ( 'all' === $key && empty( $current ) ) ) ? ' class="current"' : ( $current == $key ? 'class="current"' : '' ),
362
+					esc_url($staus_url),
363
+					(('all' === $key && empty($current))) ? ' class="current"' : ($current == $key ? 'class="current"' : ''),
365 364
 					$name,
366 365
 					$count
367 366
 				);
@@ -376,7 +375,7 @@  discard block
 block discarded – undo
376 375
 		 * @param array $views
377 376
 		 * @param Give_Payment_History_Table
378 377
 		 */
379
-		return apply_filters( 'give_payments_table_views', $views, $this );
378
+		return apply_filters('give_payments_table_views', $views, $this);
380 379
 	}
381 380
 
382 381
 	/**
@@ -390,18 +389,18 @@  discard block
 block discarded – undo
390 389
 	public function get_columns() {
391 390
 		$columns = array(
392 391
 			'cb'            => '<input type="checkbox" />', // Render a checkbox instead of text.
393
-			'donation'      => __( 'Donation', 'give' ),
394
-			'donation_form' => __( 'Donation Form', 'give' ),
395
-			'status'        => __( 'Status', 'give' ),
396
-			'date'          => __( 'Date', 'give' ),
397
-			'amount'        => __( 'Amount', 'give' ),
392
+			'donation'      => __('Donation', 'give'),
393
+			'donation_form' => __('Donation Form', 'give'),
394
+			'status'        => __('Status', 'give'),
395
+			'date'          => __('Date', 'give'),
396
+			'amount'        => __('Amount', 'give'),
398 397
 		);
399 398
 
400
-		if ( current_user_can( 'view_give_payments' ) ) {
401
-			$columns['details'] = __( 'Details', 'give' );
399
+		if (current_user_can('view_give_payments')) {
400
+			$columns['details'] = __('Details', 'give');
402 401
 		}
403 402
 
404
-		return apply_filters( 'give_payments_table_columns', $columns );
403
+		return apply_filters('give_payments_table_columns', $columns);
405 404
 	}
406 405
 
407 406
 	/**
@@ -414,14 +413,14 @@  discard block
 block discarded – undo
414 413
 	 */
415 414
 	public function get_sortable_columns() {
416 415
 		$columns = array(
417
-			'donation'      => array( 'ID', true ),
418
-			'donation_form' => array( 'donation_form', false ),
419
-			'status'        => array( 'status', false ),
420
-			'amount'        => array( 'amount', false ),
421
-			'date'          => array( 'date', false ),
416
+			'donation'      => array('ID', true),
417
+			'donation_form' => array('donation_form', false),
418
+			'status'        => array('status', false),
419
+			'amount'        => array('amount', false),
420
+			'date'          => array('date', false),
422 421
 		);
423 422
 
424
-		return apply_filters( 'give_payments_table_sortable_columns', $columns );
423
+		return apply_filters('give_payments_table_sortable_columns', $columns);
425 424
 	}
426 425
 
427 426
 	/**
@@ -447,43 +446,43 @@  discard block
 block discarded – undo
447 446
 	 *
448 447
 	 * @return string Column Name
449 448
 	 */
450
-	public function column_default( $payment, $column_name ) {
449
+	public function column_default($payment, $column_name) {
451 450
 
452
-		$single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details' ) ) );
453
-		$row_actions         = $this->get_row_actions( $payment );
451
+		$single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details')));
452
+		$row_actions         = $this->get_row_actions($payment);
454 453
 		$value               = '';
455 454
 
456
-		switch ( $column_name ) {
455
+		switch ($column_name) {
457 456
 			case 'donation' :
458
-				$serial_code = Give()->seq_donation_number->get_serial_code( $payment );
459
-				if ( current_user_can( 'view_give_payments' ) ) {
460
-					$value = Give()->tooltips->render_link( array(
461
-						'label'       => sprintf( __( 'View Donation %s', 'give' ), $serial_code ),
457
+				$serial_code = Give()->seq_donation_number->get_serial_code($payment);
458
+				if (current_user_can('view_give_payments')) {
459
+					$value = Give()->tooltips->render_link(array(
460
+						'label'       => sprintf(__('View Donation %s', 'give'), $serial_code),
462 461
 						'tag_content' => $serial_code,
463 462
 						'link'        => $single_donation_url,
464
-					) );
463
+					));
465 464
 				} else {
466 465
 					$value = $serial_code;
467 466
 				}
468 467
 
469 468
 				$value .= sprintf(
470 469
 					'&nbsp;%1$s&nbsp;%2$s<br>',
471
-					__( 'by', 'give' ),
472
-					$this->get_donor( $payment )
470
+					__('by', 'give'),
471
+					$this->get_donor($payment)
473 472
 				);
474 473
 
475
-				$value .= $this->get_donor_email( $payment );
476
-				$value .= $this->row_actions( $row_actions );
474
+				$value .= $this->get_donor_email($payment);
475
+				$value .= $this->row_actions($row_actions);
477 476
 				break;
478 477
 
479 478
 			case 'amount':
480
-				$value  = give_donation_amount( $payment, true );
481
-				$value .= sprintf( '<br><small>%1$s %2$s</small>', __( 'via', 'give' ), give_get_gateway_admin_label( $payment->gateway ) );
479
+				$value  = give_donation_amount($payment, true);
480
+				$value .= sprintf('<br><small>%1$s %2$s</small>', __('via', 'give'), give_get_gateway_admin_label($payment->gateway));
482 481
 				break;
483 482
 
484 483
 			case 'donation_form':
485
-				$form_title = empty( $payment->form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $payment->form_id ) : $payment->form_title;
486
-				$value      = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $form_title . '</a>';
484
+				$form_title = empty($payment->form_title) ? sprintf(__('Untitled (#%s)', 'give'), $payment->form_id) : $payment->form_title;
485
+				$value      = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$form_title.'</a>';
487 486
 				$level      = give_get_donation_form_title(
488 487
 					$payment,
489 488
 					array(
@@ -491,44 +490,44 @@  discard block
 block discarded – undo
491 490
 					)
492 491
 				);
493 492
 
494
-				if ( ! empty( $level ) ) {
493
+				if ( ! empty($level)) {
495 494
 					$value .= $level;
496 495
 				}
497 496
 
498 497
 				break;
499 498
 
500 499
 			case 'date':
501
-				$date  = strtotime( $payment->date );
502
-				$value = date_i18n( give_date_format(), $date );
500
+				$date  = strtotime($payment->date);
501
+				$value = date_i18n(give_date_format(), $date);
503 502
 				break;
504 503
 
505 504
 			case 'status':
506
-				$value = $this->get_payment_status( $payment );
505
+				$value = $this->get_payment_status($payment);
507 506
 				break;
508 507
 
509 508
 
510 509
 			case 'details' :
511
-				if ( current_user_can( 'view_give_payments' ) ) {
512
-					$value = Give()->tooltips->render_link( array(
513
-						'label'       => sprintf( __( 'View Donation #%s', 'give' ), $payment->ID ),
510
+				if (current_user_can('view_give_payments')) {
511
+					$value = Give()->tooltips->render_link(array(
512
+						'label'       => sprintf(__('View Donation #%s', 'give'), $payment->ID),
514 513
 						'tag_content' => '<span class="dashicons dashicons-visibility"></span>',
515 514
 						'link'        => $single_donation_url,
516 515
 						'attributes'  => array(
517 516
 							'class' => 'give-payment-details-link button button-small',
518 517
 						),
519
-					) );
518
+					));
520 519
 
521 520
 					$value = "<div class=\"give-payment-details-link-wrap\">{$value}</div>";
522 521
 				}
523 522
 				break;
524 523
 
525 524
 			default:
526
-				$value = isset( $payment->$column_name ) ? $payment->$column_name : '';
525
+				$value = isset($payment->$column_name) ? $payment->$column_name : '';
527 526
 				break;
528 527
 
529 528
 		}// End switch().
530 529
 
531
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name );
530
+		return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name);
532 531
 	}
533 532
 
534 533
 	/**
@@ -541,22 +540,22 @@  discard block
 block discarded – undo
541 540
 	 *
542 541
 	 * @return string Data shown in the Email column
543 542
 	 */
544
-	public function get_donor_email( $payment ) {
543
+	public function get_donor_email($payment) {
545 544
 
546
-		$email = give_get_payment_user_email( $payment->ID );
545
+		$email = give_get_payment_user_email($payment->ID);
547 546
 
548
-		if ( empty( $email ) ) {
549
-			$email = __( '(unknown)', 'give' );
547
+		if (empty($email)) {
548
+			$email = __('(unknown)', 'give');
550 549
 		}
551 550
 
552 551
 
553
-		$value = Give()->tooltips->render_link( array(
552
+		$value = Give()->tooltips->render_link(array(
554 553
 			'link'        => "mailto:{$email}",
555
-			'label'       => __( 'Email donor', 'give' ),
554
+			'label'       => __('Email donor', 'give'),
556 555
 			'tag_content' => $email,
557
-		) );
556
+		));
558 557
 
559
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' );
558
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'email');
560 559
 	}
561 560
 
562 561
 	/**
@@ -568,18 +567,18 @@  discard block
 block discarded – undo
568 567
 	 *
569 568
 	 * @return array $actions
570 569
 	 */
571
-	function get_row_actions( $payment ) {
570
+	function get_row_actions($payment) {
572 571
 
573 572
 		$actions = array();
574
-		$email   = give_get_payment_user_email( $payment->ID );
573
+		$email   = give_get_payment_user_email($payment->ID);
575 574
 
576 575
 		// Add search term string back to base URL.
577
-		$search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' );
578
-		if ( ! empty( $search_terms ) ) {
579
-			$this->base_url = add_query_arg( 's', $search_terms, $this->base_url );
576
+		$search_terms = (isset($_GET['s']) ? trim($_GET['s']) : '');
577
+		if ( ! empty($search_terms)) {
578
+			$this->base_url = add_query_arg('s', $search_terms, $this->base_url);
580 579
 		}
581 580
 
582
-		if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) {
581
+		if (give_is_payment_complete($payment->ID) && ! empty($email)) {
583 582
 
584 583
 			$actions['email_links'] = sprintf(
585 584
 				'<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url(
@@ -589,12 +588,12 @@  discard block
 block discarded – undo
589 588
 						'purchase_id' => $payment->ID,
590 589
 					), $this->base_url
591 590
 				), 'give_payment_nonce'
592
-			), sprintf( __( 'Resend Donation %s Receipt', 'give' ), $payment->ID ), __( 'Resend Receipt', 'give' )
591
+			), sprintf(__('Resend Donation %s Receipt', 'give'), $payment->ID), __('Resend Receipt', 'give')
593 592
 			);
594 593
 
595 594
 		}
596 595
 
597
-		if ( current_user_can( 'view_give_payments' ) ) {
596
+		if (current_user_can('view_give_payments')) {
598 597
 			$actions['delete'] = sprintf(
599 598
 				'<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>',
600 599
 				wp_nonce_url(
@@ -604,11 +603,11 @@  discard block
 block discarded – undo
604 603
 							'purchase_id' => $payment->ID,
605 604
 						), $this->base_url
606 605
 					), 'give_donation_nonce'
607
-				), sprintf( __( 'Delete Donation %s', 'give' ), $payment->ID ), __( 'Delete', 'give' )
606
+				), sprintf(__('Delete Donation %s', 'give'), $payment->ID), __('Delete', 'give')
608 607
 			);
609 608
 		}
610 609
 
611
-		return apply_filters( 'give_payment_row_actions', $actions, $payment );
610
+		return apply_filters('give_payment_row_actions', $actions, $payment);
612 611
 	}
613 612
 
614 613
 
@@ -622,30 +621,30 @@  discard block
 block discarded – undo
622 621
 	 *
623 622
 	 * @return string Data shown in the Email column
624 623
 	 */
625
-	function get_payment_status( $payment ) {
624
+	function get_payment_status($payment) {
626 625
 		$value = sprintf(
627 626
 			'<div class="give-donation-status status-%1$s"><span class="give-donation-status-icon"></span>&nbsp;%2$s</div>',
628 627
 			$payment->status,
629
-			give_get_payment_status( $payment, true )
628
+			give_get_payment_status($payment, true)
630 629
 		);
631 630
 
632
-		if ( $payment->mode == 'test' ) {
633
-			$value .= Give()->tooltips->render_span( array(
634
-				'label'       => __( 'This donation was made in test mode.', 'give' ),
635
-				'tag_content' => __( 'Test', 'give' ),
631
+		if ($payment->mode == 'test') {
632
+			$value .= Give()->tooltips->render_span(array(
633
+				'label'       => __('This donation was made in test mode.', 'give'),
634
+				'tag_content' => __('Test', 'give'),
636 635
 				'attributes'  => array(
637 636
 					'class' => 'give-item-label give-item-label-orange give-test-mode-transactions-label',
638 637
 				),
639 638
 
640 639
 
641
-			) );
640
+			));
642 641
 		}
643 642
 
644
-		if ( true === $payment->import && true === (bool) apply_filters( 'give_payment_show_importer_label', false ) ) {
643
+		if (true === $payment->import && true === (bool) apply_filters('give_payment_show_importer_label', false)) {
645 644
 			$value .= sprintf(
646 645
 				'&nbsp;<span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="%1$s">%2$s</span>',
647
-				__( 'This donation was imported.', 'give' ),
648
-				__( 'Import', 'give' )
646
+				__('This donation was imported.', 'give'),
647
+				__('Import', 'give')
649 648
 			);
650 649
 		}
651 650
 
@@ -662,8 +661,8 @@  discard block
 block discarded – undo
662 661
 	 *
663 662
 	 * @return string Displays a checkbox.
664 663
 	 */
665
-	public function column_cb( $payment ) {
666
-		return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID );
664
+	public function column_cb($payment) {
665
+		return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID);
667 666
 	}
668 667
 
669 668
 	/**
@@ -676,8 +675,8 @@  discard block
 block discarded – undo
676 675
 	 *
677 676
 	 * @return string Displays a checkbox.
678 677
 	 */
679
-	public function get_payment_id( $payment ) {
680
-		return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>';
678
+	public function get_payment_id($payment) {
679
+		return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>';
681 680
 	}
682 681
 
683 682
 	/**
@@ -690,32 +689,32 @@  discard block
 block discarded – undo
690 689
 	 *
691 690
 	 * @return string Data shown in the User column
692 691
 	 */
693
-	public function get_donor( $payment ) {
692
+	public function get_donor($payment) {
694 693
 
695
-		$donor_id           = give_get_payment_donor_id( $payment->ID );
696
-		$donor_billing_name = give_get_donor_name_by( $payment->ID, 'donation' );
697
-		$donor_name         = give_get_donor_name_by( $donor_id, 'donor' );
694
+		$donor_id           = give_get_payment_donor_id($payment->ID);
695
+		$donor_billing_name = give_get_donor_name_by($payment->ID, 'donation');
696
+		$donor_name         = give_get_donor_name_by($donor_id, 'donor');
698 697
 
699 698
 		$value = '';
700
-		if ( ! empty( $donor_id ) ) {
699
+		if ( ! empty($donor_id)) {
701 700
 
702 701
 			// Check whether the donor name and WP_User name is same or not.
703
-			if ( sanitize_title( $donor_billing_name ) !== sanitize_title( $donor_name ) ) {
704
-				$value .= $donor_billing_name . ' (';
702
+			if (sanitize_title($donor_billing_name) !== sanitize_title($donor_name)) {
703
+				$value .= $donor_billing_name.' (';
705 704
 			}
706 705
 
707
-			$value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>';
706
+			$value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>';
708 707
 
709 708
 			// Check whether the donor name and WP_User name is same or not.
710
-			if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) {
709
+			if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) {
711 710
 				$value .= ')';
712 711
 			}
713 712
 		} else {
714
-			$email  = give_get_payment_user_email( $payment->ID );
715
-			$value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . __( '(donor missing)', 'give' ) . '</a>';
713
+			$email  = give_get_payment_user_email($payment->ID);
714
+			$value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.__('(donor missing)', 'give').'</a>';
716 715
 		}
717 716
 
718
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' );
717
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor');
719 718
 	}
720 719
 
721 720
 	/**
@@ -728,20 +727,20 @@  discard block
 block discarded – undo
728 727
 	 */
729 728
 	public function get_bulk_actions() {
730 729
 		$actions = array(
731
-			'delete'                 => __( 'Delete', 'give' ),
732
-			'set-status-publish'     => __( 'Set To Completed', 'give' ),
733
-			'set-status-pending'     => __( 'Set To Pending', 'give' ),
734
-			'set-status-processing'  => __( 'Set To Processing', 'give' ),
735
-			'set-status-refunded'    => __( 'Set To Refunded', 'give' ),
736
-			'set-status-revoked'     => __( 'Set To Revoked', 'give' ),
737
-			'set-status-failed'      => __( 'Set To Failed', 'give' ),
738
-			'set-status-cancelled'   => __( 'Set To Cancelled', 'give' ),
739
-			'set-status-abandoned'   => __( 'Set To Abandoned', 'give' ),
740
-			'set-status-preapproval' => __( 'Set To Preapproval', 'give' ),
741
-			'resend-receipt'         => __( 'Resend Email Receipts', 'give' ),
730
+			'delete'                 => __('Delete', 'give'),
731
+			'set-status-publish'     => __('Set To Completed', 'give'),
732
+			'set-status-pending'     => __('Set To Pending', 'give'),
733
+			'set-status-processing'  => __('Set To Processing', 'give'),
734
+			'set-status-refunded'    => __('Set To Refunded', 'give'),
735
+			'set-status-revoked'     => __('Set To Revoked', 'give'),
736
+			'set-status-failed'      => __('Set To Failed', 'give'),
737
+			'set-status-cancelled'   => __('Set To Cancelled', 'give'),
738
+			'set-status-abandoned'   => __('Set To Abandoned', 'give'),
739
+			'set-status-preapproval' => __('Set To Preapproval', 'give'),
740
+			'resend-receipt'         => __('Resend Email Receipts', 'give'),
742 741
 		);
743 742
 
744
-		return apply_filters( 'give_payments_table_bulk_actions', $actions );
743
+		return apply_filters('give_payments_table_bulk_actions', $actions);
745 744
 	}
746 745
 
747 746
 	/**
@@ -753,59 +752,59 @@  discard block
 block discarded – undo
753 752
 	 * @return void
754 753
 	 */
755 754
 	public function process_bulk_action() {
756
-		$ids    = isset( $_GET['payment'] ) ? $_GET['payment'] : false;
755
+		$ids    = isset($_GET['payment']) ? $_GET['payment'] : false;
757 756
 		$action = $this->current_action();
758 757
 
759
-		if ( ! is_array( $ids ) ) {
760
-			$ids = array( $ids );
758
+		if ( ! is_array($ids)) {
759
+			$ids = array($ids);
761 760
 		}
762 761
 
763
-		if ( empty( $action ) ) {
762
+		if (empty($action)) {
764 763
 			return;
765 764
 		}
766 765
 
767
-		foreach ( $ids as $id ) {
766
+		foreach ($ids as $id) {
768 767
 
769 768
 			// Detect when a bulk action is being triggered.
770
-			switch ( $this->current_action() ) {
769
+			switch ($this->current_action()) {
771 770
 
772 771
 				case 'delete':
773
-					give_delete_donation( $id );
772
+					give_delete_donation($id);
774 773
 					break;
775 774
 
776 775
 				case 'set-status-publish':
777
-					give_update_payment_status( $id, 'publish' );
776
+					give_update_payment_status($id, 'publish');
778 777
 					break;
779 778
 
780 779
 				case 'set-status-pending':
781
-					give_update_payment_status( $id, 'pending' );
780
+					give_update_payment_status($id, 'pending');
782 781
 					break;
783 782
 
784 783
 				case 'set-status-processing':
785
-					give_update_payment_status( $id, 'processing' );
784
+					give_update_payment_status($id, 'processing');
786 785
 					break;
787 786
 
788 787
 				case 'set-status-refunded':
789
-					give_update_payment_status( $id, 'refunded' );
788
+					give_update_payment_status($id, 'refunded');
790 789
 					break;
791 790
 				case 'set-status-revoked':
792
-					give_update_payment_status( $id, 'revoked' );
791
+					give_update_payment_status($id, 'revoked');
793 792
 					break;
794 793
 
795 794
 				case 'set-status-failed':
796
-					give_update_payment_status( $id, 'failed' );
795
+					give_update_payment_status($id, 'failed');
797 796
 					break;
798 797
 
799 798
 				case 'set-status-cancelled':
800
-					give_update_payment_status( $id, 'cancelled' );
799
+					give_update_payment_status($id, 'cancelled');
801 800
 					break;
802 801
 
803 802
 				case 'set-status-abandoned':
804
-					give_update_payment_status( $id, 'abandoned' );
803
+					give_update_payment_status($id, 'abandoned');
805 804
 					break;
806 805
 
807 806
 				case 'set-status-preapproval':
808
-					give_update_payment_status( $id, 'preapproval' );
807
+					give_update_payment_status($id, 'preapproval');
809 808
 					break;
810 809
 
811 810
 				case 'resend-receipt':
@@ -814,7 +813,7 @@  discard block
 block discarded – undo
814 813
 					 *
815 814
 					 * @since 2.0
816 815
 					 */
817
-					do_action( 'give_donation-receipt_email_notification', $id );
816
+					do_action('give_donation-receipt_email_notification', $id);
818 817
 					break;
819 818
 			}// End switch().
820 819
 
@@ -826,7 +825,7 @@  discard block
 block discarded – undo
826 825
 			 *
827 826
 			 * @since 1.7
828 827
 			 */
829
-			do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() );
828
+			do_action('give_payments_table_do_bulk_action', $id, $this->current_action());
830 829
 		}// End foreach().
831 830
 
832 831
 	}
@@ -843,32 +842,32 @@  discard block
 block discarded – undo
843 842
 
844 843
 		$args = array();
845 844
 
846
-		if ( isset( $_GET['user'] ) ) {
847
-			$args['user'] = urldecode( $_GET['user'] );
848
-		} elseif ( isset( $_GET['donor'] ) ) {
849
-			$args['donor'] = absint( $_GET['donor'] );
850
-		} elseif ( isset( $_GET['s'] ) ) {
851
-			$is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false;
852
-			if ( $is_user ) {
853
-				$args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) );
854
-				unset( $args['s'] );
845
+		if (isset($_GET['user'])) {
846
+			$args['user'] = urldecode($_GET['user']);
847
+		} elseif (isset($_GET['donor'])) {
848
+			$args['donor'] = absint($_GET['donor']);
849
+		} elseif (isset($_GET['s'])) {
850
+			$is_user = strpos($_GET['s'], strtolower('user:')) !== false;
851
+			if ($is_user) {
852
+				$args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s']))));
853
+				unset($args['s']);
855 854
 			} else {
856
-				$args['s'] = sanitize_text_field( $_GET['s'] );
855
+				$args['s'] = sanitize_text_field($_GET['s']);
857 856
 			}
858 857
 		}
859 858
 
860
-		if ( ! empty( $_GET['start-date'] ) ) {
861
-			$args['start-date'] = urldecode( $_GET['start-date'] );
859
+		if ( ! empty($_GET['start-date'])) {
860
+			$args['start-date'] = urldecode($_GET['start-date']);
862 861
 		}
863 862
 
864
-		if ( ! empty( $_GET['end-date'] ) ) {
865
-			$args['end-date'] = urldecode( $_GET['end-date'] );
863
+		if ( ! empty($_GET['end-date'])) {
864
+			$args['end-date'] = urldecode($_GET['end-date']);
866 865
 		}
867 866
 
868
-		$args['form_id'] = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
869
-		$args['gateway'] = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null;
867
+		$args['form_id'] = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null;
868
+		$args['gateway'] = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null;
870 869
 
871
-		$payment_count           = give_count_payments( $args );
870
+		$payment_count           = give_count_payments($args);
872 871
 		$this->complete_count    = $payment_count->publish;
873 872
 		$this->pending_count     = $payment_count->pending;
874 873
 		$this->processing_count  = $payment_count->processing;
@@ -879,7 +878,7 @@  discard block
 block discarded – undo
879 878
 		$this->abandoned_count   = $payment_count->abandoned;
880 879
 		$this->preapproval_count = $payment_count->preapproval;
881 880
 
882
-		foreach ( $payment_count as $count ) {
881
+		foreach ($payment_count as $count) {
883 882
 			$this->total_count += $count;
884 883
 		}
885 884
 
@@ -897,25 +896,25 @@  discard block
 block discarded – undo
897 896
 	public function payments_data() {
898 897
 
899 898
 		$per_page   = $this->per_page;
900
-		$orderby    = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID';
901
-		$order      = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
902
-		$user       = isset( $_GET['user'] ) ? $_GET['user'] : null;
903
-		$donor      = isset( $_GET['donor'] ) ? $_GET['donor'] : null;
904
-		$status     = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys();
905
-		$meta_key   = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null;
906
-		$year       = isset( $_GET['year'] ) ? $_GET['year'] : null;
907
-		$month      = isset( $_GET['m'] ) ? $_GET['m'] : null;
908
-		$day        = isset( $_GET['day'] ) ? $_GET['day'] : null;
909
-		$search     = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null;
910
-		$start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null;
911
-		$end_date   = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date;
912
-		$form_id    = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
913
-		$gateway    = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null;
899
+		$orderby    = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID';
900
+		$order      = isset($_GET['order']) ? $_GET['order'] : 'DESC';
901
+		$user       = isset($_GET['user']) ? $_GET['user'] : null;
902
+		$donor      = isset($_GET['donor']) ? $_GET['donor'] : null;
903
+		$status     = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys();
904
+		$meta_key   = isset($_GET['meta_key']) ? $_GET['meta_key'] : null;
905
+		$year       = isset($_GET['year']) ? $_GET['year'] : null;
906
+		$month      = isset($_GET['m']) ? $_GET['m'] : null;
907
+		$day        = isset($_GET['day']) ? $_GET['day'] : null;
908
+		$search     = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
909
+		$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
910
+		$end_date   = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date;
911
+		$form_id    = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null;
912
+		$gateway    = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null;
914 913
 
915 914
 		$args = array(
916 915
 			'output'     => 'payments',
917 916
 			'number'     => $per_page,
918
-			'page'       => isset( $_GET['paged'] ) ? $_GET['paged'] : null,
917
+			'page'       => isset($_GET['paged']) ? $_GET['paged'] : null,
919 918
 			'orderby'    => $orderby,
920 919
 			'order'      => $order,
921 920
 			'user'       => $user,
@@ -932,9 +931,9 @@  discard block
 block discarded – undo
932 931
 			'give_forms' => $form_id,
933 932
 		);
934 933
 
935
-		if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) {
934
+		if (is_string($search) && false !== strpos($search, 'txn:')) {
936 935
 			$args['search_in_notes'] = true;
937
-			$args['s']               = trim( str_replace( 'txn:', '', $args['s'] ) );
936
+			$args['s']               = trim(str_replace('txn:', '', $args['s']));
938 937
 		}
939 938
 
940 939
 		/**
@@ -942,9 +941,9 @@  discard block
 block discarded – undo
942 941
 		 *
943 942
 		 * @since 1.8.18
944 943
 		 */
945
-		$args = (array) apply_filters( 'give_payment_table_payments_query', $args );
944
+		$args = (array) apply_filters('give_payment_table_payments_query', $args);
946 945
 
947
-		$p_query = new Give_Payments_Query( $args );
946
+		$p_query = new Give_Payments_Query($args);
948 947
 
949 948
 		return $p_query->get_payments();
950 949
 
@@ -965,17 +964,17 @@  discard block
 block discarded – undo
965 964
 	 */
966 965
 	public function prepare_items() {
967 966
 
968
-		wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) );
967
+		wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's'));
969 968
 
970 969
 		$columns  = $this->get_columns();
971 970
 		$hidden   = array(); // No hidden columns.
972 971
 		$sortable = $this->get_sortable_columns();
973 972
 		$data     = $this->payments_data();
974
-		$status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
973
+		$status   = isset($_GET['status']) ? $_GET['status'] : 'any';
975 974
 
976
-		$this->_column_headers = array( $columns, $hidden, $sortable );
975
+		$this->_column_headers = array($columns, $hidden, $sortable);
977 976
 
978
-		switch ( $status ) {
977
+		switch ($status) {
979 978
 			case 'publish':
980 979
 				$total_items = $this->complete_count;
981 980
 				break;
@@ -1008,8 +1007,8 @@  discard block
 block discarded – undo
1008 1007
 				break;
1009 1008
 			default:
1010 1009
 				// Retrieve the count of the non-default-Give status.
1011
-				$count       = wp_count_posts( 'give_payment' );
1012
-				$total_items = isset( $count->{$status} ) ? $count->{$status} : 0;
1010
+				$count       = wp_count_posts('give_payment');
1011
+				$total_items = isset($count->{$status} ) ? $count->{$status} : 0;
1013 1012
 				break;
1014 1013
 		}
1015 1014
 
@@ -1020,7 +1019,7 @@  discard block
 block discarded – undo
1020 1019
 		 *
1021 1020
 		 * @since 1.8.19
1022 1021
 		 */
1023
-		$total_items = (int) apply_filters( 'give_payment_table_pagination_total_count', $total_items, $this );
1022
+		$total_items = (int) apply_filters('give_payment_table_pagination_total_count', $total_items, $this);
1024 1023
 
1025 1024
 		$this->set_pagination_args(
1026 1025
 			array(
@@ -1028,7 +1027,7 @@  discard block
 block discarded – undo
1028 1027
 				// We have to calculate the total number of items.
1029 1028
 				'per_page'    => $this->per_page,
1030 1029
 				// We have to determine how many items to show on a page.
1031
-				'total_pages' => ceil( $total_items / $this->per_page ),
1030
+				'total_pages' => ceil($total_items / $this->per_page),
1032 1031
 				// We have to calculate the total number of pages.
1033 1032
 			)
1034 1033
 		);
Please login to merge, or discard this patch.
includes/admin/tools/logs/class-api-requests-logs-list-table.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@
 block discarded – undo
187 187
 	 * @access public
188 188
 	 * @since  1.0
189 189
 	 *
190
-	 * @return string|bool String if search is present, false otherwise
190
+	 * @return string|false String if search is present, false otherwise
191 191
 	 */
192 192
 	public function get_search() {
193 193
 		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
51
-			'ajax'     => false,// Does this table support ajax?
52
-		) );
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51
+			'ajax'     => false, // Does this table support ajax?
52
+		));
53 53
 	}
54 54
 
55 55
 	/**
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return void
65 65
 	 */
66
-	public function search_box( $text, $input_id ) {
67
-		$input_id = $input_id . '-search-input';
66
+	public function search_box($text, $input_id) {
67
+		$input_id = $input_id.'-search-input';
68 68
 
69
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
70
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
69
+		if ( ! empty($_REQUEST['orderby'])) {
70
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
71 71
 		}
72
-		if ( ! empty( $_REQUEST['order'] ) ) {
73
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
72
+		if ( ! empty($_REQUEST['order'])) {
73
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
74 74
 		}
75 75
 		?>
76 76
 		<p class="search-box" role="search">
77 77
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
78 78
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
79
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
79
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?>
80 80
 		</p>
81 81
 		<?php
82 82
 	}
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function get_columns() {
93 93
 		$columns = array(
94
-			'ID'      => __( 'Log ID', 'give' ),
95
-			'ip'      => __( 'Request IP', 'give' ),
96
-			'date'    => __( 'Date', 'give' ),
97
-			'details' => __( 'Request Details', 'give' ),
94
+			'ID'      => __('Log ID', 'give'),
95
+			'ip'      => __('Request IP', 'give'),
96
+			'date'    => __('Date', 'give'),
97
+			'details' => __('Request Details', 'give'),
98 98
 		);
99 99
 
100 100
 		return $columns;
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return string Column Name
113 113
 	 */
114
-	public function column_default( $item, $column_name ) {
115
-		switch ( $column_name ) {
114
+	public function column_default($item, $column_name) {
115
+		switch ($column_name) {
116 116
 			default:
117
-				return esc_attr( $item[ $column_name ] );
117
+				return esc_attr($item[$column_name]);
118 118
 		}
119 119
 	}
120 120
 
@@ -128,52 +128,52 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return void
130 130
 	 */
131
-	public function column_details( $item ) {
132
-		echo Give()->tooltips->render_link( array(
133
-			'label'       => __( 'View Request', 'give' ),
131
+	public function column_details($item) {
132
+		echo Give()->tooltips->render_link(array(
133
+			'label'       => __('View Request', 'give'),
134 134
 			'tag_content' => '<span class="dashicons dashicons-visibility"></span>',
135 135
 			'link'        => "#TB_inline?width=640&amp;inlineId=log-details-{$item['ID']}",
136 136
 			'attributes'  => array(
137 137
 				'class' => 'thickbox give-error-log-details-link button button-small',
138 138
 			),
139
-		) );
139
+		));
140 140
 		?>
141 141
 		<div id="log-details-<?php echo $item['ID']; ?>" style="display:none;">
142 142
 			<?php
143 143
 			// Print API Request.
144 144
 			echo sprintf(
145 145
 				'<p><strong>%1$s</strong></p><div>%2$s</div>',
146
-				__( 'API Request:', 'give' ),
147
-				Give()->logs->logmeta_db->get_meta( $item['ID'], '_give_log_api_query', true )
146
+				__('API Request:', 'give'),
147
+				Give()->logs->logmeta_db->get_meta($item['ID'], '_give_log_api_query', true)
148 148
 			);
149 149
 
150 150
 			// Print Log Content, if not empty.
151
-			if ( ! empty( $item['log_content'] ) ) {
151
+			if ( ! empty($item['log_content'])) {
152 152
 				echo sprintf(
153 153
 					'<p><strong>%1$s</strong></p><div>%2$s</div>',
154
-					__( 'Error', 'give' ),
155
-					esc_html( $item['log_content'] )
154
+					__('Error', 'give'),
155
+					esc_html($item['log_content'])
156 156
 				);
157 157
 			}
158 158
 
159 159
 			// Print User who requested data using API.
160 160
 			echo sprintf(
161 161
 				'<p><strong>%1$s</strong></p><div>%2$s</div>',
162
-				__( 'API User:', 'give' ),
163
-				Give()->logs->logmeta_db->get_meta( $item['ID'], '_give_log_user', true )
162
+				__('API User:', 'give'),
163
+				Give()->logs->logmeta_db->get_meta($item['ID'], '_give_log_user', true)
164 164
 			);
165 165
 
166 166
 			// Print the logged key used by API.
167 167
 			echo sprintf(
168 168
 				'<p><strong>%1$s</strong></p><div>%2$s</div>',
169
-				__( 'API Key:', 'give' ),
170
-				Give()->logs->logmeta_db->get_meta( $item['ID'], '_give_log_key', true )
169
+				__('API Key:', 'give'),
170
+				Give()->logs->logmeta_db->get_meta($item['ID'], '_give_log_key', true)
171 171
 			);
172 172
 
173 173
 			// Print the API Request Date.
174 174
 			echo sprintf(
175 175
 				'<p><strong>%1$s</strong></p><div>%2$s</div>',
176
-				__( 'Request Date:', 'give' ),
176
+				__('Request Date:', 'give'),
177 177
 				$item['log_date']
178 178
 			);
179 179
 			?>
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @return string|bool String if search is present, false otherwise
191 191
 	 */
192 192
 	public function get_search() {
193
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
193
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
194 194
 	}
195 195
 
196 196
 
@@ -206,19 +206,19 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @param string $which
208 208
 	 */
209
-	protected function display_tablenav( $which ) {
210
-		if ( 'top' === $which ) {
211
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
209
+	protected function display_tablenav($which) {
210
+		if ('top' === $which) {
211
+			wp_nonce_field('bulk-'.$this->_args['plural']);
212 212
 		}
213 213
 		?>
214
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
214
+		<div class="tablenav <?php echo esc_attr($which); ?>">
215 215
 
216 216
 			<div class="alignleft actions bulkactions">
217
-				<?php $this->bulk_actions( $which ); ?>
217
+				<?php $this->bulk_actions($which); ?>
218 218
 			</div>
219 219
 			<?php
220
-			$this->extra_tablenav( $which );
221
-			$this->pagination( $which );
220
+			$this->extra_tablenav($which);
221
+			$this->pagination($which);
222 222
 			?>
223 223
 
224 224
 			<br class="clear"/>
@@ -241,40 +241,40 @@  discard block
 block discarded – undo
241 241
 		$meta_query = array();
242 242
 		$search     = $this->get_search();
243 243
 
244
-		if ( $search ) {
245
-			if ( filter_var( $search, FILTER_VALIDATE_IP ) ) {
244
+		if ($search) {
245
+			if (filter_var($search, FILTER_VALIDATE_IP)) {
246 246
 
247 247
 				// This is an IP address search.
248 248
 				$key = '_give_log_request_ip';
249 249
 
250
-			} elseif ( is_email( $search ) ) {
250
+			} elseif (is_email($search)) {
251 251
 
252 252
 				// This is an email search.
253
-				$userdata = get_user_by( 'email', $search );
253
+				$userdata = get_user_by('email', $search);
254 254
 
255
-				if ( $userdata ) {
255
+				if ($userdata) {
256 256
 					$search = $userdata->ID;
257 257
 				}
258 258
 
259 259
 				$key = '_give_log_user';
260 260
 
261
-			} elseif ( 32 === strlen( $search ) ) {
261
+			} elseif (32 === strlen($search)) {
262 262
 
263 263
 				// Look for an API key.
264 264
 				$key = '_give_log_key';
265 265
 
266
-			} elseif ( stristr( $search, 'token:' ) ) {
266
+			} elseif (stristr($search, 'token:')) {
267 267
 
268 268
 				// Look for an API token.
269
-				$search = str_ireplace( 'token:', '', $search );
269
+				$search = str_ireplace('token:', '', $search);
270 270
 				$key    = '_give_log_token';
271 271
 
272 272
 			} else {
273 273
 
274 274
 				// This is (probably) a user ID search.
275
-				$userdata = get_userdata( $search );
275
+				$userdata = get_userdata($search);
276 276
 
277
-				if ( $userdata ) {
277
+				if ($userdata) {
278 278
 					$search = $userdata->ID;
279 279
 				}
280 280
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 * @return int Current page number
303 303
 	 */
304 304
 	public function get_paged() {
305
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
305
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
306 306
 	}
307 307
 
308 308
 	/**
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @return void
317 317
 	 */
318
-	function bulk_actions( $which = '' ) {
318
+	function bulk_actions($which = '') {
319 319
 		give_log_views();
320 320
 	}
321 321
 
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
 			'posts_per_page' => $this->per_page,
338 338
 		);
339 339
 
340
-		$logs = Give()->logs->get_connected_logs( $log_query );
340
+		$logs = Give()->logs->get_connected_logs($log_query);
341 341
 
342
-		if ( $logs ) {
343
-			foreach ( $logs as $log ) {
342
+		if ($logs) {
343
+			foreach ($logs as $log) {
344 344
 
345 345
 				$logs_data[] = array(
346 346
 					'ID'          => $log->ID,
347
-					'ip'          => Give()->logs->logmeta_db->get_meta( $log->ID, '_give_log_request_ip', true ),
347
+					'ip'          => Give()->logs->logmeta_db->get_meta($log->ID, '_give_log_request_ip', true),
348 348
 					'date'        => $log->log_date,
349 349
 					'log_content' => $log->log_content,
350 350
 					'log_date'    => $log->log_date,
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 		$columns               = $this->get_columns();
373 373
 		$hidden                = array(); // No hidden columns
374 374
 		$sortable              = $this->get_sortable_columns();
375
-		$this->_column_headers = array( $columns, $hidden, $sortable );
375
+		$this->_column_headers = array($columns, $hidden, $sortable);
376 376
 		$this->items           = $this->get_logs();
377
-		$total_items           = Give()->logs->get_log_count( 0, 'api_request' );
377
+		$total_items           = Give()->logs->get_log_count(0, 'api_request');
378 378
 
379
-		$this->set_pagination_args( array(
379
+		$this->set_pagination_args(array(
380 380
 				'total_items' => $total_items,
381 381
 				'per_page'    => $this->per_page,
382
-				'total_pages' => ceil( $total_items / $this->per_page ),
382
+				'total_pages' => ceil($total_items / $this->per_page),
383 383
 			)
384 384
 		);
385 385
 	}
Please login to merge, or discard this patch.
includes/class-give-cache.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @param  string $cache_key
123 123
 	 * @param  bool   $custom_key
124
-	 * @param  mixed  $query_args
124
+	 * @param  string  $query_args
125 125
 	 *
126 126
 	 * @return mixed
127 127
 	 */
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @param bool  $force If set to true then all cached values will be delete instead of only expired
239 239
 	 *
240
-	 * @return bool
240
+	 * @return false|null
241 241
 	 */
242 242
 	public static function delete_all_expired( $force = false ) {
243 243
 		global $wpdb;
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 	 * @since  2.0
670 670
 	 * @access private
671 671
 	 *
672
-	 * @param $group
672
+	 * @param string $group
673 673
 	 *
674 674
 	 * @return mixed
675 675
 	 */
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@
 block discarded – undo
203 203
 		if ( ! self::is_valid_cache_key( $cache_key ) ) {
204 204
 			if( empty( $cache_key ) ) {
205 205
 				return new WP_Error( 'give_empty_cache_key', __( 'Do not pass invalid empty cache key', 'give' ) );
206
-			}elseif ( ! $custom_key ) {
206
+			} elseif ( ! $custom_key ) {
207 207
 				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
208 208
 			}
209 209
 
Please login to merge, or discard this patch.
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @return static
54 54
 	 */
55 55
 	public static function get_instance() {
56
-		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) {
56
+		if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) {
57 57
 			self::$instance = new Give_Cache();
58 58
 		}
59 59
 
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function setup() {
70 70
 		// Currently enable cache only for backend.
71
-		self::$instance->is_cache = ( defined( 'GIVE_CACHE' ) ? GIVE_CACHE : give_is_setting_enabled( give_get_option( 'cache', 'enabled' ) ) ) && is_admin();
71
+		self::$instance->is_cache = (defined('GIVE_CACHE') ? GIVE_CACHE : give_is_setting_enabled(give_get_option('cache', 'enabled'))) && is_admin();
72 72
 
73 73
 		// weekly delete all expired cache.
74
-		Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) );
74
+		Give_Cron::add_weekly_event(array($this, 'delete_all_expired'));
75 75
 
76
-		add_action( 'save_post_give_forms', array( $this, 'delete_form_related_cache' ) );
77
-		add_action( 'save_post_give_payment', array( $this, 'delete_payment_related_cache' ) );
78
-		add_action( 'give_deleted_give-donors_cache', array( $this, 'delete_donor_related_cache' ), 10, 3 );
79
-		add_action( 'give_deleted_give-donations_cache', array( $this, 'delete_donations_related_cache' ), 10, 3 );
76
+		add_action('save_post_give_forms', array($this, 'delete_form_related_cache'));
77
+		add_action('save_post_give_payment', array($this, 'delete_payment_related_cache'));
78
+		add_action('give_deleted_give-donors_cache', array($this, 'delete_donor_related_cache'), 10, 3);
79
+		add_action('give_deleted_give-donations_cache', array($this, 'delete_donations_related_cache'), 10, 3);
80 80
 
81
-		add_action( 'give_save_settings_give_settings', array( __CLASS__, 'flush_cache' ) );
81
+		add_action('give_save_settings_give_settings', array(__CLASS__, 'flush_cache'));
82 82
 
83
-		add_action( 'wp', array( __CLASS__,  'prevent_caching' ) );
84
-		add_action( 'admin_notices', array( $this, '__notices' ) );
83
+		add_action('wp', array(__CLASS__, 'prevent_caching'));
84
+		add_action('admin_notices', array($this, '__notices'));
85 85
 	}
86 86
 
87 87
 	/**
@@ -92,19 +92,19 @@  discard block
 block discarded – undo
92 92
 	 * @credit WooCommerce
93 93
 	 */
94 94
 	public static function prevent_caching() {
95
-		if ( ! is_blog_installed() ) {
95
+		if ( ! is_blog_installed()) {
96 96
 			return;
97 97
 		}
98 98
 
99
-		$page_ids = array_filter( array(
100
-			give_get_option( 'success_page' ),
101
-			give_get_option( 'failure_page' ),
102
-			give_get_option( 'history_page' ),
103
-		) );
99
+		$page_ids = array_filter(array(
100
+			give_get_option('success_page'),
101
+			give_get_option('failure_page'),
102
+			give_get_option('history_page'),
103
+		));
104 104
 
105 105
 		if (
106
-			is_page( $page_ids )
107
-			|| is_singular( 'give_forms' )
106
+			is_page($page_ids)
107
+			|| is_singular('give_forms')
108 108
 		) {
109 109
 			self::set_nocache_constants();
110 110
 			nocache_headers();
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return mixed
124 124
 	 */
125
-	public static function set_nocache_constants( $return = true ) {
126
-		give_maybe_define_constant( 'DONOTCACHEPAGE', true );
127
-		give_maybe_define_constant( 'DONOTCACHEOBJECT', true );
128
-		give_maybe_define_constant( 'DONOTCACHEDB', true );
125
+	public static function set_nocache_constants($return = true) {
126
+		give_maybe_define_constant('DONOTCACHEPAGE', true);
127
+		give_maybe_define_constant('DONOTCACHEOBJECT', true);
128
+		give_maybe_define_constant('DONOTCACHEDB', true);
129 129
 
130 130
 		return $return;
131 131
 	}
@@ -138,18 +138,18 @@  discard block
 block discarded – undo
138 138
 	 * @credit WooCommerce
139 139
 	 */
140 140
 	public function __notices() {
141
-		if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) {
141
+		if ( ! function_exists('w3tc_pgcache_flush') || ! function_exists('w3_instance')) {
142 142
 			return;
143 143
 		}
144 144
 
145
-		$config   = w3_instance( 'W3_Config' );
146
-		$enabled  = $config->get_integer( 'dbcache.enabled' );
147
-		$settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) );
145
+		$config   = w3_instance('W3_Config');
146
+		$enabled  = $config->get_integer('dbcache.enabled');
147
+		$settings = array_map('trim', $config->get_array('dbcache.reject.sql'));
148 148
 
149
-		if ( $enabled && ! in_array( 'give', $settings, true ) ) {
149
+		if ($enabled && ! in_array('give', $settings, true)) {
150 150
 			?>
151 151
 			<div class="error">
152
-				<p><?php echo wp_kses_post( sprintf( __( 'In order for <strong>database caching</strong> to work with Give you must add %1$s to the "Ignored query stems" option in <a href="%2$s">W3 Total Cache settings</a>.', 'give' ), '<code>give</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache#dbcache_reject_sql' ) ) ) ); ?></p>
152
+				<p><?php echo wp_kses_post(sprintf(__('In order for <strong>database caching</strong> to work with Give you must add %1$s to the "Ignored query stems" option in <a href="%2$s">W3 Total Cache settings</a>.', 'give'), '<code>give</code>', esc_url(admin_url('admin.php?page=w3tc_dbcache#dbcache_reject_sql')))); ?></p>
153 153
 			</div>
154 154
 			<?php
155 155
 		}
@@ -166,18 +166,18 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return string
168 168
 	 */
169
-	public static function get_key( $action, $query_args = null, $is_prefix = true ) {
169
+	public static function get_key($action, $query_args = null, $is_prefix = true) {
170 170
 		// Bailout.
171
-		if ( empty( $action ) ) {
172
-			return new WP_Error( 'give_invalid_cache_key_action', __( 'Do not pass empty action to generate cache key.', 'give' ) );
171
+		if (empty($action)) {
172
+			return new WP_Error('give_invalid_cache_key_action', __('Do not pass empty action to generate cache key.', 'give'));
173 173
 		}
174 174
 
175 175
 		// Set cache key.
176 176
 		$cache_key = $is_prefix ? "give_cache_{$action}" : $action;
177 177
 
178 178
 		// Bailout.
179
-		if ( ! empty( $query_args ) ) {
180
-			$cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 );
179
+		if ( ! empty($query_args)) {
180
+			$cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15);
181 181
 		}
182 182
 
183 183
 		/**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		 *
186 186
 		 * @since 2.0
187 187
 		 */
188
-		return apply_filters( 'give_get_cache_key', $cache_key, $action, $query_args );
188
+		return apply_filters('give_get_cache_key', $cache_key, $action, $query_args);
189 189
 	}
190 190
 
191 191
 	/**
@@ -199,28 +199,28 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return mixed
201 201
 	 */
202
-	public static function get( $cache_key, $custom_key = false, $query_args = array() ) {
203
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
204
-			if( empty( $cache_key ) ) {
205
-				return new WP_Error( 'give_empty_cache_key', __( 'Do not pass invalid empty cache key', 'give' ) );
206
-			}elseif ( ! $custom_key ) {
207
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
202
+	public static function get($cache_key, $custom_key = false, $query_args = array()) {
203
+		if ( ! self::is_valid_cache_key($cache_key)) {
204
+			if (empty($cache_key)) {
205
+				return new WP_Error('give_empty_cache_key', __('Do not pass invalid empty cache key', 'give'));
206
+			}elseif ( ! $custom_key) {
207
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
208 208
 			}
209 209
 
210
-			$cache_key = self::get_key( $cache_key, $query_args );
210
+			$cache_key = self::get_key($cache_key, $query_args);
211 211
 		}
212 212
 
213
-		$option = get_option( $cache_key );
213
+		$option = get_option($cache_key);
214 214
 
215 215
 		// Backward compatibility (<1.8.7).
216
-		if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) {
216
+		if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) {
217 217
 			return $option;
218 218
 		}
219 219
 
220 220
 		// Get current time.
221
-		$current_time = current_time( 'timestamp', 1 );
221
+		$current_time = current_time('timestamp', 1);
222 222
 
223
-		if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) {
223
+		if (empty($option['expiration']) || ($current_time < $option['expiration'])) {
224 224
 			$option = $option['data'];
225 225
 		} else {
226 226
 			$option = false;
@@ -242,23 +242,23 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return mixed
244 244
 	 */
245
-	public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) {
246
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
247
-			if ( ! $custom_key ) {
248
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
245
+	public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) {
246
+		if ( ! self::is_valid_cache_key($cache_key)) {
247
+			if ( ! $custom_key) {
248
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
249 249
 			}
250 250
 
251
-			$cache_key = self::get_key( $cache_key, $query_args );
251
+			$cache_key = self::get_key($cache_key, $query_args);
252 252
 		}
253 253
 
254 254
 		$option_value = array(
255 255
 			'data'       => $data,
256
-			'expiration' => ! is_null( $expiration )
257
-				? ( $expiration + current_time( 'timestamp', 1 ) )
256
+			'expiration' => ! is_null($expiration)
257
+				? ($expiration + current_time('timestamp', 1))
258 258
 				: null,
259 259
 		);
260 260
 
261
-		$result = update_option( $cache_key, $option_value, false );
261
+		$result = update_option($cache_key, $option_value, false);
262 262
 
263 263
 		return $result;
264 264
 	}
@@ -274,27 +274,27 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return bool|WP_Error
276 276
 	 */
277
-	public static function delete( $cache_keys ) {
277
+	public static function delete($cache_keys) {
278 278
 		$result       = true;
279 279
 		$invalid_keys = array();
280 280
 
281
-		if ( ! empty( $cache_keys ) ) {
282
-			$cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys );
281
+		if ( ! empty($cache_keys)) {
282
+			$cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys);
283 283
 
284
-			foreach ( $cache_keys as $cache_key ) {
285
-				if ( ! self::is_valid_cache_key( $cache_key ) ) {
284
+			foreach ($cache_keys as $cache_key) {
285
+				if ( ! self::is_valid_cache_key($cache_key)) {
286 286
 					$invalid_keys[] = $cache_key;
287 287
 					$result         = false;
288 288
 				}
289 289
 
290
-				delete_option( $cache_key );
290
+				delete_option($cache_key);
291 291
 			}
292 292
 		}
293 293
 
294
-		if ( ! $result ) {
294
+		if ( ! $result) {
295 295
 			$result = new WP_Error(
296 296
 				'give_invalid_cache_key',
297
-				__( 'Cache key format should be give_cache_*', 'give' ),
297
+				__('Cache key format should be give_cache_*', 'give'),
298 298
 				$invalid_keys
299 299
 			);
300 300
 		}
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @return bool
317 317
 	 */
318
-	public static function delete_all_expired( $force = false ) {
318
+	public static function delete_all_expired($force = false) {
319 319
 		global $wpdb;
320 320
 		$options = $wpdb->get_results(
321 321
 			$wpdb->prepare(
@@ -329,30 +329,30 @@  discard block
 block discarded – undo
329 329
 		);
330 330
 
331 331
 		// Bailout.
332
-		if ( empty( $options ) ) {
332
+		if (empty($options)) {
333 333
 			return false;
334 334
 		}
335 335
 
336
-		$current_time = current_time( 'timestamp', 1 );
336
+		$current_time = current_time('timestamp', 1);
337 337
 
338 338
 		// Delete log cache.
339
-		foreach ( $options as $option ) {
340
-			$option['option_value'] = maybe_unserialize( $option['option_value'] );
339
+		foreach ($options as $option) {
340
+			$option['option_value'] = maybe_unserialize($option['option_value']);
341 341
 
342 342
 			if (
343 343
 				(
344
-					! self::is_valid_cache_key( $option['option_name'] )
345
-					|| ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7).
346
-					|| ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7).
347
-					|| empty( $option['option_value']['expiration'] )
348
-					|| ( $current_time < $option['option_value']['expiration'] )
344
+					! self::is_valid_cache_key($option['option_name'])
345
+					|| ! is_array($option['option_value']) // Backward compatibility (<1.8.7).
346
+					|| ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7).
347
+					|| empty($option['option_value']['expiration'])
348
+					|| ($current_time < $option['option_value']['expiration'])
349 349
 				)
350 350
 				&& ! $force
351 351
 			) {
352 352
 				continue;
353 353
 			}
354 354
 
355
-			self::delete( $option['option_name'] );
355
+			self::delete($option['option_name']);
356 356
 		}
357 357
 	}
358 358
 
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
 	 *
371 371
 	 * @return array
372 372
 	 */
373
-	public static function get_options_like( $option_name, $fields = false ) {
373
+	public static function get_options_like($option_name, $fields = false) {
374 374
 		global $wpdb;
375 375
 
376 376
 		$field_names = $fields ? 'option_name, option_value' : 'option_name';
377 377
 
378
-		if ( $fields ) {
378
+		if ($fields) {
379 379
 			$options = $wpdb->get_results(
380 380
 				$wpdb->prepare(
381 381
 					"SELECT {$field_names }
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 			);
400 400
 		}
401 401
 
402
-		if ( ! empty( $options ) && $fields ) {
403
-			foreach ( $options as $index => $option ) {
404
-				$option['option_value'] = maybe_unserialize( $option['option_value'] );
405
-				$options[ $index ]      = $option;
402
+		if ( ! empty($options) && $fields) {
403
+			foreach ($options as $index => $option) {
404
+				$option['option_value'] = maybe_unserialize($option['option_value']);
405
+				$options[$index]      = $option;
406 406
 			}
407 407
 		}
408 408
 
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 	 *
420 420
 	 * @return bool
421 421
 	 */
422
-	public static function is_valid_cache_key( $cache_key ) {
423
-		$is_valid = ( false !== strpos( $cache_key, 'give_cache_' ) );
422
+	public static function is_valid_cache_key($cache_key) {
423
+		$is_valid = (false !== strpos($cache_key, 'give_cache_'));
424 424
 
425 425
 
426 426
 		/**
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		 *
429 429
 		 * @since 2.0
430 430
 		 */
431
-		return apply_filters( 'give_is_valid_cache_key', $is_valid, $cache_key );
431
+		return apply_filters('give_is_valid_cache_key', $is_valid, $cache_key);
432 432
 	}
433 433
 
434 434
 
@@ -443,14 +443,14 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @return mixed
445 445
 	 */
446
-	public static function get_group( $id, $group = '' ) {
446
+	public static function get_group($id, $group = '') {
447 447
 		$cached_data = null;
448 448
 
449 449
 		// Bailout.
450
-		if ( self::$instance->is_cache && ! empty( $id ) ) {
451
-			$group = self::$instance->filter_group_name( $group );
450
+		if (self::$instance->is_cache && ! empty($id)) {
451
+			$group = self::$instance->filter_group_name($group);
452 452
 
453
-			$cached_data = wp_cache_get( $id, $group );
453
+			$cached_data = wp_cache_get($id, $group);
454 454
 			$cached_data = false !== $cached_data ? $cached_data : null;
455 455
 		}
456 456
 
@@ -470,17 +470,17 @@  discard block
 block discarded – undo
470 470
 	 *
471 471
 	 * @return bool
472 472
 	 */
473
-	public static function set_group( $id, $data, $group = '', $expire = 0 ) {
473
+	public static function set_group($id, $data, $group = '', $expire = 0) {
474 474
 		$status = false;
475 475
 
476 476
 		// Bailout.
477
-		if ( ! self::$instance->is_cache || empty( $id ) ) {
477
+		if ( ! self::$instance->is_cache || empty($id)) {
478 478
 			return $status;
479 479
 		}
480 480
 
481
-		$group = self::$instance->filter_group_name( $group );
481
+		$group = self::$instance->filter_group_name($group);
482 482
 
483
-		$status = wp_cache_set( $id, $data, $group, $expire );
483
+		$status = wp_cache_set($id, $data, $group, $expire);
484 484
 
485 485
 		return $status;
486 486
 	}
@@ -496,15 +496,15 @@  discard block
 block discarded – undo
496 496
 	 *
497 497
 	 * @return bool
498 498
 	 */
499
-	public static function set_db_query( $id, $data ) {
499
+	public static function set_db_query($id, $data) {
500 500
 		$status = false;
501 501
 
502 502
 		// Bailout.
503
-		if ( ! self::$instance->is_cache || empty( $id ) ) {
503
+		if ( ! self::$instance->is_cache || empty($id)) {
504 504
 			return $status;
505 505
 		}
506 506
 
507
-		return self::set_group( $id, $data, 'give-db-queries', 0 );
507
+		return self::set_group($id, $data, 'give-db-queries', 0);
508 508
 	}
509 509
 
510 510
 	/**
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @return mixed
519 519
 	 */
520
-	public static function get_db_query( $id ) {
521
-		return self::get_group( $id, 'give-db-queries' );
520
+	public static function get_db_query($id) {
521
+		return self::get_group($id, 'give-db-queries');
522 522
 	}
523 523
 
524 524
 	/**
@@ -533,21 +533,21 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return bool
535 535
 	 */
536
-	public static function delete_group( $ids, $group = '', $expire = 0 ) {
536
+	public static function delete_group($ids, $group = '', $expire = 0) {
537 537
 		$status = false;
538 538
 
539 539
 		// Bailout.
540
-		if ( ! self::$instance->is_cache || empty( $ids ) ) {
540
+		if ( ! self::$instance->is_cache || empty($ids)) {
541 541
 			return $status;
542 542
 		}
543 543
 
544 544
 		$group_prefix = $group;
545
-		$group = self::$instance->filter_group_name( $group );
545
+		$group = self::$instance->filter_group_name($group);
546 546
 
547 547
 		// Delete single or multiple cache items from cache.
548
-		if ( ! is_array( $ids ) ) {
549
-			$status = wp_cache_delete( $ids, $group );
550
-			self::$instance->get_incrementer( true );
548
+		if ( ! is_array($ids)) {
549
+			$status = wp_cache_delete($ids, $group);
550
+			self::$instance->get_incrementer(true);
551 551
 
552 552
 			/**
553 553
 			 * Fire action when cache deleted for specific id.
@@ -558,12 +558,12 @@  discard block
 block discarded – undo
558 558
 			 * @param string $group
559 559
 			 * @param int    $expire
560 560
 			 */
561
-			do_action( "give_deleted_{$group_prefix}_cache", $ids, $group, $expire, $status );
561
+			do_action("give_deleted_{$group_prefix}_cache", $ids, $group, $expire, $status);
562 562
 
563 563
 		} else {
564
-			foreach ( $ids as $id ) {
565
-				$status = wp_cache_delete( $id, $group );
566
-				self::$instance->get_incrementer( true );
564
+			foreach ($ids as $id) {
565
+				$status = wp_cache_delete($id, $group);
566
+				self::$instance->get_incrementer(true);
567 567
 
568 568
 				/**
569 569
 				 * Fire action when cache deleted for specific id .
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 				 * @param string $group
575 575
 				 * @param int    $expire
576 576
 				 */
577
-				do_action( "give_deleted_{$group_prefix}_cache", $id, $group, $expire, $status );
577
+				do_action("give_deleted_{$group_prefix}_cache", $id, $group, $expire, $status);
578 578
 			}
579 579
 		}
580 580
 
@@ -591,15 +591,15 @@  discard block
 block discarded – undo
591 591
 	 *
592 592
 	 * @param int $form_id
593 593
 	 */
594
-	public function delete_form_related_cache( $form_id ) {
594
+	public function delete_form_related_cache($form_id) {
595 595
 		// If this is just a revision, don't send the email.
596
-		if ( wp_is_post_revision( $form_id ) ) {
596
+		if (wp_is_post_revision($form_id)) {
597 597
 			return;
598 598
 		}
599 599
 
600 600
 		$donation_query = new Give_Payments_Query(
601 601
 			array(
602
-				'number'     => - 1,
602
+				'number'     => -1,
603 603
 				'give_forms' => $form_id,
604 604
 				'output'     => '',
605 605
 				'fields'     => 'ids',
@@ -608,15 +608,15 @@  discard block
 block discarded – undo
608 608
 
609 609
 		$donations = $donation_query->get_payments();
610 610
 
611
-		if ( ! empty( $donations ) ) {
611
+		if ( ! empty($donations)) {
612 612
 			/* @var Give_Payment $donation */
613
-			foreach ( $donations as $donation_id ) {
614
-				wp_cache_delete( $donation_id, $this->filter_group_name( 'give-donations' ) );
615
-				wp_cache_delete( give_get_payment_donor_id( $donation_id ), $this->filter_group_name( 'give-donors' ) );
613
+			foreach ($donations as $donation_id) {
614
+				wp_cache_delete($donation_id, $this->filter_group_name('give-donations'));
615
+				wp_cache_delete(give_get_payment_donor_id($donation_id), $this->filter_group_name('give-donors'));
616 616
 			}
617 617
 		}
618 618
 
619
-		self::$instance->get_incrementer( true );
619
+		self::$instance->get_incrementer(true);
620 620
 	}
621 621
 
622 622
 	/**
@@ -628,19 +628,19 @@  discard block
 block discarded – undo
628 628
 	 *
629 629
 	 * @param int $donation_id
630 630
 	 */
631
-	public function delete_payment_related_cache( $donation_id ) {
631
+	public function delete_payment_related_cache($donation_id) {
632 632
 		// If this is just a revision, don't send the email.
633
-		if ( wp_is_post_revision( $donation_id ) ) {
633
+		if (wp_is_post_revision($donation_id)) {
634 634
 			return;
635 635
 		}
636 636
 
637
-		if ( $donation_id && ( $donor_id = give_get_payment_donor_id( $donation_id ) ) ) {
638
-			wp_cache_delete( $donor_id, $this->filter_group_name( 'give-donors' ) );
637
+		if ($donation_id && ($donor_id = give_get_payment_donor_id($donation_id))) {
638
+			wp_cache_delete($donor_id, $this->filter_group_name('give-donors'));
639 639
 		}
640 640
 
641
-		wp_cache_delete( $donation_id, $this->filter_group_name( 'give-donations' ) );
641
+		wp_cache_delete($donation_id, $this->filter_group_name('give-donations'));
642 642
 
643
-		self::$instance->get_incrementer( true );
643
+		self::$instance->get_incrementer(true);
644 644
 	}
645 645
 
646 646
 	/**
@@ -654,18 +654,18 @@  discard block
 block discarded – undo
654 654
 	 * @param string $group
655 655
 	 * @param int    $expire
656 656
 	 */
657
-	public function delete_donor_related_cache( $id, $group, $expire ) {
658
-		$donation_ids = Give()->donors->get_column( 'payment_ids', $id );
657
+	public function delete_donor_related_cache($id, $group, $expire) {
658
+		$donation_ids = Give()->donors->get_column('payment_ids', $id);
659 659
 
660
-		if ( ! empty( $donation_ids ) ) {
661
-			$donation_ids = array_map( 'trim', (array) explode( ',', trim( $donation_ids  ) ) );
660
+		if ( ! empty($donation_ids)) {
661
+			$donation_ids = array_map('trim', (array) explode(',', trim($donation_ids)));
662 662
 
663
-			foreach ( $donation_ids as $donation ) {
664
-				wp_cache_delete( $donation, $this->filter_group_name( 'give-donations' ) );
663
+			foreach ($donation_ids as $donation) {
664
+				wp_cache_delete($donation, $this->filter_group_name('give-donations'));
665 665
 			}
666 666
 		}
667 667
 
668
-		self::$instance->get_incrementer( true );
668
+		self::$instance->get_incrementer(true);
669 669
 	}
670 670
 
671 671
 	/**
@@ -679,12 +679,12 @@  discard block
 block discarded – undo
679 679
 	 * @param string $group
680 680
 	 * @param int    $expire
681 681
 	 */
682
-	public function delete_donations_related_cache( $id, $group, $expire ) {
683
-		if ( $id && ( $donor_id = give_get_payment_donor_id( $id ) ) ) {
684
-			wp_cache_delete( $donor_id, $this->filter_group_name( 'give-donors' ) );
682
+	public function delete_donations_related_cache($id, $group, $expire) {
683
+		if ($id && ($donor_id = give_get_payment_donor_id($id))) {
684
+			wp_cache_delete($donor_id, $this->filter_group_name('give-donors'));
685 685
 		}
686 686
 
687
-		self::$instance->get_incrementer( true );
687
+		self::$instance->get_incrementer(true);
688 688
 	}
689 689
 
690 690
 
@@ -702,12 +702,12 @@  discard block
 block discarded – undo
702 702
 	 *
703 703
 	 * @return string
704 704
 	 */
705
-	public function get_incrementer( $refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries' ) {
706
-		$incrementer_value = wp_cache_get( $incrementer_key );
705
+	public function get_incrementer($refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries') {
706
+		$incrementer_value = wp_cache_get($incrementer_key);
707 707
 
708
-		if ( false === $incrementer_value || true === $refresh ) {
709
-			$incrementer_value = microtime( true );
710
-			wp_cache_set( $incrementer_key, $incrementer_value );
708
+		if (false === $incrementer_value || true === $refresh) {
709
+			$incrementer_value = microtime(true);
710
+			wp_cache_set($incrementer_key, $incrementer_value);
711 711
 		}
712 712
 
713 713
 		return $incrementer_value;
@@ -725,21 +725,21 @@  discard block
 block discarded – undo
725 725
 	 *
726 726
 	 * @return bool
727 727
 	 */
728
-	public static function flush_cache( $force = false ) {
728
+	public static function flush_cache($force = false) {
729 729
 		if (
730 730
 			$force
731
-			|| ( Give_Admin_Settings::is_saving_settings() && isset( $_POST['cache'] ) && give_is_setting_enabled( give_clean( $_POST['cache'] ) ) )
732
-			|| ( wp_doing_ajax() &&  isset( $_GET['action'] ) && 'give_cache_flush' === give_clean( $_GET['action'] ) )
731
+			|| (Give_Admin_Settings::is_saving_settings() && isset($_POST['cache']) && give_is_setting_enabled(give_clean($_POST['cache'])))
732
+			|| (wp_doing_ajax() && isset($_GET['action']) && 'give_cache_flush' === give_clean($_GET['action']))
733 733
 		) {
734
-			self::$instance->get_incrementer( true );
735
-			self::$instance->get_incrementer( true, 'give-cache-incrementer' );
734
+			self::$instance->get_incrementer(true);
735
+			self::$instance->get_incrementer(true, 'give-cache-incrementer');
736 736
 
737 737
 			/**
738 738
 			 * Fire the action when all cache deleted.
739 739
 			 *
740 740
 			 * @since 2.1.0
741 741
 			 */
742
-			do_action( 'give_flushed_cache' );
742
+			do_action('give_flushed_cache');
743 743
 
744 744
 			return true;
745 745
 		}
@@ -758,23 +758,23 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @return mixed
760 760
 	 */
761
-	private function filter_group_name( $group ) {
761
+	private function filter_group_name($group) {
762 762
 		/**
763 763
 		 * Filter the group name
764 764
 		 *
765 765
 		 * @since 2.1.0
766 766
 		 */
767
-		$filtered_group = apply_filters( 'give_cache_filter_group_name', '', $group );
767
+		$filtered_group = apply_filters('give_cache_filter_group_name', '', $group);
768 768
 
769
-		if ( empty( $filtered_group ) ) {
769
+		if (empty($filtered_group)) {
770 770
 
771
-			switch ( $group ) {
771
+			switch ($group) {
772 772
 				case 'give-db-queries':
773 773
 					$incrementer = self::$instance->get_incrementer();
774 774
 					break;
775 775
 
776 776
 				default:
777
-					$incrementer = self::$instance->get_incrementer( false, 'give-cache-incrementer' );
777
+					$incrementer = self::$instance->get_incrementer(false, 'give-cache-incrementer');
778 778
 
779 779
 			}
780 780
 
Please login to merge, or discard this patch.
includes/class-give-db-donors.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 * NOTE: This should not be called directly as it does not make necessary changes to
208 208
 	 * the payment meta and logs. Use give_donor_delete() instead.
209 209
 	 *
210
-	 * @param  bool|string|int $_id_or_email ID or Email of Donor.
210
+	 * @param  integer $_id_or_email ID or Email of Donor.
211 211
 	 *
212 212
 	 * @since  1.0
213 213
 	 * @access public
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	 * @access public
408 408
 	 *
409 409
 	 * @param  string $field ID or email. Default is 'id'.
410
-	 * @param  mixed  $value The Customer ID or email to search. Default is 0.
410
+	 * @param  integer  $value The Customer ID or email to search. Default is 0.
411 411
 	 *
412 412
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
413 413
 	 */
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		$this->bc_200_params();
43 43
 
44 44
 		// Set hooks and register table only if instance loading first time.
45
-		if ( ! ( Give()->donors instanceof Give_DB_Donors ) ) {
45
+		if ( ! (Give()->donors instanceof Give_DB_Donors)) {
46 46
 			// Install table.
47 47
 			$this->register_table();
48 48
 		}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			'purchase_value'  => 0.00,
93 93
 			'purchase_count'  => 0,
94 94
 			'notes'           => '',
95
-			'date_created'    => date( 'Y-m-d H:i:s' ),
95
+			'date_created'    => date('Y-m-d H:i:s'),
96 96
 			'token'           => '',
97 97
 			'verify_key'      => '',
98 98
 			'verify_throttle' => '',
@@ -109,40 +109,40 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return int|bool
111 111
 	 */
112
-	public function add( $data = array() ) {
112
+	public function add($data = array()) {
113 113
 
114 114
 		$defaults = array(
115 115
 			'payment_ids' => '',
116 116
 		);
117 117
 
118
-		$args = wp_parse_args( $data, $defaults );
118
+		$args = wp_parse_args($data, $defaults);
119 119
 
120
-		if ( empty( $args['email'] ) ) {
120
+		if (empty($args['email'])) {
121 121
 			return false;
122 122
 		}
123 123
 
124
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
125
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
124
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
125
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
126 126
 		}
127 127
 
128
-		$donor = $this->get_donor_by( 'email', $args['email'] );
128
+		$donor = $this->get_donor_by('email', $args['email']);
129 129
 
130 130
 		// update an existing donor.
131
-		if ( $donor ) {
131
+		if ($donor) {
132 132
 
133 133
 			// Update the payment IDs attached to the donor
134
-			if ( ! empty( $args['payment_ids'] ) ) {
134
+			if ( ! empty($args['payment_ids'])) {
135 135
 
136
-				if ( empty( $donor->payment_ids ) ) {
136
+				if (empty($donor->payment_ids)) {
137 137
 
138 138
 					$donor->payment_ids = $args['payment_ids'];
139 139
 
140 140
 				} else {
141 141
 
142
-					$existing_ids       = array_map( 'absint', explode( ',', $donor->payment_ids ) );
143
-					$payment_ids        = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
144
-					$payment_ids        = array_merge( $payment_ids, $existing_ids );
145
-					$donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
142
+					$existing_ids       = array_map('absint', explode(',', $donor->payment_ids));
143
+					$payment_ids        = array_map('absint', explode(',', $args['payment_ids']));
144
+					$payment_ids        = array_merge($payment_ids, $existing_ids);
145
+					$donor->payment_ids = implode(',', array_unique(array_values($payment_ids)));
146 146
 
147 147
 				}
148 148
 
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
 
151 151
 			}
152 152
 
153
-			$this->update( $donor->id, $args );
153
+			$this->update($donor->id, $args);
154 154
 
155 155
 			return $donor->id;
156 156
 
157 157
 		} else {
158 158
 
159
-			return $this->insert( $args, 'donor' );
159
+			return $this->insert($args, 'donor');
160 160
 
161 161
 		}
162 162
 
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return bool
175 175
 	 */
176
-	public function update( $row_id, $data = array(), $where = '' ) {
176
+	public function update($row_id, $data = array(), $where = '') {
177 177
 
178
-		$status = parent::update( $row_id, $data, $where );
178
+		$status = parent::update($row_id, $data, $where);
179 179
 
180
-		if ( $status ) {
181
-			Give_Cache::delete_group( $row_id, 'give-donors' );
180
+		if ($status) {
181
+			Give_Cache::delete_group($row_id, 'give-donors');
182 182
 		}
183 183
 
184 184
 		return $status;
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @return int
194 194
 	 */
195
-	public function insert( $data, $type = '' ) {
196
-		$donor_id = parent::insert( $data, $type );
195
+	public function insert($data, $type = '') {
196
+		$donor_id = parent::insert($data, $type);
197 197
 
198
-		if ( $donor_id ) {
199
-			Give_Cache::delete_group( $donor_id, 'give-donors' );
198
+		if ($donor_id) {
199
+			Give_Cache::delete_group($donor_id, 'give-donors');
200 200
 		}
201 201
 
202 202
 		return $donor_id;
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return bool|int
217 217
 	 */
218
-	public function delete( $_id_or_email = false ) {
218
+	public function delete($_id_or_email = false) {
219 219
 
220
-		if ( empty( $_id_or_email ) ) {
220
+		if (empty($_id_or_email)) {
221 221
 			return false;
222 222
 		}
223 223
 
224
-		$column = is_email( $_id_or_email ) ? 'email' : 'id';
225
-		$donor  = $this->get_donor_by( $column, $_id_or_email );
224
+		$column = is_email($_id_or_email) ? 'email' : 'id';
225
+		$donor  = $this->get_donor_by($column, $_id_or_email);
226 226
 
227
-		if ( $donor->id > 0 ) {
227
+		if ($donor->id > 0) {
228 228
 
229 229
 			global $wpdb;
230 230
 
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 			 *
234 234
 			 * @since 1.8.14
235 235
 			 */
236
-			Give()->donor_meta->delete_all_meta( $donor->id );
236
+			Give()->donor_meta->delete_all_meta($donor->id);
237 237
 
238 238
 			// Cache already deleted in delete_all_meta fn.
239 239
 
240
-			return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) );
240
+			return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d'));
241 241
 
242 242
 		} else {
243 243
 			return false;
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @return bool|int
260 260
 	 */
261
-	public function delete_by_user_id( $user_id = false ) {
261
+	public function delete_by_user_id($user_id = false) {
262 262
 		global $wpdb;
263 263
 
264
-		if ( empty( $user_id ) ) {
264
+		if (empty($user_id)) {
265 265
 			return false;
266 266
 		}
267 267
 
@@ -270,14 +270,14 @@  discard block
 block discarded – undo
270 270
 		 *
271 271
 		 * @since 1.8.14
272 272
 		 */
273
-		$donor = new Give_Donor( $user_id, true );
274
-		if ( ! empty( $donor->id ) ) {
275
-			Give()->donor_meta->delete_all_meta( $donor->id );
273
+		$donor = new Give_Donor($user_id, true);
274
+		if ( ! empty($donor->id)) {
275
+			Give()->donor_meta->delete_all_meta($donor->id);
276 276
 		}
277 277
 
278 278
 		// Cache is already deleted in delete_all_meta fn.
279 279
 
280
-		return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) );
280
+		return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d'));
281 281
 	}
282 282
 
283 283
 	/**
@@ -291,14 +291,14 @@  discard block
 block discarded – undo
291 291
 	 *
292 292
 	 * @return bool          True is exists, false otherwise.
293 293
 	 */
294
-	public function exists( $value = '', $field = 'email' ) {
294
+	public function exists($value = '', $field = 'email') {
295 295
 
296 296
 		$columns = $this->get_columns();
297
-		if ( ! array_key_exists( $field, $columns ) ) {
297
+		if ( ! array_key_exists($field, $columns)) {
298 298
 			return false;
299 299
 		}
300 300
 
301
-		return (bool) $this->get_column_by( 'id', $field, $value );
301
+		return (bool) $this->get_column_by('id', $field, $value);
302 302
 
303 303
 	}
304 304
 
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @return bool
315 315
 	 */
316
-	public function attach_payment( $donor_id = 0, $payment_id = 0 ) {
316
+	public function attach_payment($donor_id = 0, $payment_id = 0) {
317 317
 
318
-		$donor = new Give_Donor( $donor_id );
318
+		$donor = new Give_Donor($donor_id);
319 319
 
320
-		if ( empty( $donor->id ) ) {
320
+		if (empty($donor->id)) {
321 321
 			return false;
322 322
 		}
323 323
 
324 324
 		// Attach the payment, but don't increment stats, as this function previously did not
325
-		return $donor->attach_payment( $payment_id, false );
325
+		return $donor->attach_payment($payment_id, false);
326 326
 
327 327
 	}
328 328
 
@@ -337,16 +337,16 @@  discard block
 block discarded – undo
337 337
 	 *
338 338
 	 * @return bool
339 339
 	 */
340
-	public function remove_payment( $donor_id = 0, $payment_id = 0 ) {
340
+	public function remove_payment($donor_id = 0, $payment_id = 0) {
341 341
 
342
-		$donor = new Give_Donor( $donor_id );
342
+		$donor = new Give_Donor($donor_id);
343 343
 
344
-		if ( ! $donor ) {
344
+		if ( ! $donor) {
345 345
 			return false;
346 346
 		}
347 347
 
348 348
 		// Remove the payment, but don't decrease stats, as this function previously did not
349
-		return $donor->remove_payment( $payment_id, false );
349
+		return $donor->remove_payment($payment_id, false);
350 350
 
351 351
 	}
352 352
 
@@ -360,18 +360,18 @@  discard block
 block discarded – undo
360 360
 	 *
361 361
 	 * @return bool
362 362
 	 */
363
-	public function increment_stats( $donor_id = 0, $amount = 0.00 ) {
363
+	public function increment_stats($donor_id = 0, $amount = 0.00) {
364 364
 
365
-		$donor = new Give_Donor( $donor_id );
365
+		$donor = new Give_Donor($donor_id);
366 366
 
367
-		if ( empty( $donor->id ) ) {
367
+		if (empty($donor->id)) {
368 368
 			return false;
369 369
 		}
370 370
 
371 371
 		$increased_count = $donor->increase_purchase_count();
372
-		$increased_value = $donor->increase_value( $amount );
372
+		$increased_value = $donor->increase_value($amount);
373 373
 
374
-		return ( $increased_count && $increased_value ) ? true : false;
374
+		return ($increased_count && $increased_value) ? true : false;
375 375
 
376 376
 	}
377 377
 
@@ -386,18 +386,18 @@  discard block
 block discarded – undo
386 386
 	 *
387 387
 	 * @return bool
388 388
 	 */
389
-	public function decrement_stats( $donor_id = 0, $amount = 0.00 ) {
389
+	public function decrement_stats($donor_id = 0, $amount = 0.00) {
390 390
 
391
-		$donor = new Give_Donor( $donor_id );
391
+		$donor = new Give_Donor($donor_id);
392 392
 
393
-		if ( ! $donor ) {
393
+		if ( ! $donor) {
394 394
 			return false;
395 395
 		}
396 396
 
397 397
 		$decreased_count = $donor->decrease_donation_count();
398
-		$decreased_value = $donor->decrease_value( $amount );
398
+		$decreased_value = $donor->decrease_value($amount);
399 399
 
400
-		return ( $decreased_count && $decreased_value ) ? true : false;
400
+		return ($decreased_count && $decreased_value) ? true : false;
401 401
 
402 402
 	}
403 403
 
@@ -412,44 +412,44 @@  discard block
 block discarded – undo
412 412
 	 *
413 413
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
414 414
 	 */
415
-	public function get_donor_by( $field = 'id', $value = 0 ) {
416
-		$value = sanitize_text_field( $value );
415
+	public function get_donor_by($field = 'id', $value = 0) {
416
+		$value = sanitize_text_field($value);
417 417
 
418 418
 		// Bailout.
419
-		if ( empty( $field ) || empty( $value ) ) {
419
+		if (empty($field) || empty($value)) {
420 420
 			return null;
421 421
 		}
422 422
 
423 423
 		// Verify values.
424
-		if ( 'id' === $field || 'user_id' === $field ) {
424
+		if ('id' === $field || 'user_id' === $field) {
425 425
 			// Make sure the value is numeric to avoid casting objects, for example,
426 426
 			// to int 1.
427
-			if ( ! is_numeric( $value ) ) {
427
+			if ( ! is_numeric($value)) {
428 428
 				return false;
429 429
 			}
430 430
 
431
-			$value = absint( $value );
431
+			$value = absint($value);
432 432
 
433
-			if ( $value < 1 ) {
433
+			if ($value < 1) {
434 434
 				return false;
435 435
 			}
436 436
 
437
-		} elseif ( 'email' === $field ) {
437
+		} elseif ('email' === $field) {
438 438
 
439
-			if ( ! is_email( $value ) ) {
439
+			if ( ! is_email($value)) {
440 440
 				return false;
441 441
 			}
442 442
 
443
-			$value = trim( $value );
443
+			$value = trim($value);
444 444
 		}
445 445
 
446 446
 		// Bailout
447
-		if ( ! $value ) {
447
+		if ( ! $value) {
448 448
 			return false;
449 449
 		}
450 450
 
451 451
 		// Set query params.
452
-		switch ( $field ) {
452
+		switch ($field) {
453 453
 			case 'id':
454 454
 				$args['donor'] = $value;
455 455
 				break;
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 		}
465 465
 
466 466
 		// Get donors.
467
-		$donor = new Give_Donors_Query( $args );
467
+		$donor = new Give_Donors_Query($args);
468 468
 
469
-		if ( ! $donor = $donor->get_donors() ) {
469
+		if ( ! $donor = $donor->get_donors()) {
470 470
 			// Look for donor from an additional email.
471 471
 			$args = array(
472 472
 				'meta_query' => array(
@@ -477,15 +477,15 @@  discard block
 block discarded – undo
477 477
 				),
478 478
 			);
479 479
 
480
-			$donor = new Give_Donors_Query( $args );
480
+			$donor = new Give_Donors_Query($args);
481 481
 			$donor = $donor->get_donors();
482 482
 
483
-			if ( empty( $donor ) ) {
483
+			if (empty($donor)) {
484 484
 				return false;
485 485
 			}
486 486
 		}
487 487
 
488
-		return current( $donor );
488
+		return current($donor);
489 489
 	}
490 490
 
491 491
 	/**
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
 	 *
499 499
 	 * @return array|object|null Donors array or object. Null if not found.
500 500
 	 */
501
-	public function get_donors( $args = array() ) {
502
-		$this->bc_1814_params( $args );
501
+	public function get_donors($args = array()) {
502
+		$this->bc_1814_params($args);
503 503
 
504
-		$donors = new Give_Donors_Query( $args );
504
+		$donors = new Give_Donors_Query($args);
505 505
 
506 506
 		return $donors->get_donors();
507 507
 
@@ -518,21 +518,21 @@  discard block
 block discarded – undo
518 518
 	 *
519 519
 	 * @return int         Total number of donors.
520 520
 	 */
521
-	public function count( $args = array() ) {
522
-		$this->bc_1814_params( $args );
521
+	public function count($args = array()) {
522
+		$this->bc_1814_params($args);
523 523
 		$args['count'] = true;
524 524
 
525
-		$cache_key = md5( 'give_donors_count' . serialize( $args ) );
526
-		$count     = Give_Cache::get_group( $cache_key, 'donors' );
525
+		$cache_key = md5('give_donors_count'.serialize($args));
526
+		$count     = Give_Cache::get_group($cache_key, 'donors');
527 527
 
528
-		if ( is_null( $count ) ) {
529
-			$donors = new Give_Donors_Query( $args );
528
+		if (is_null($count)) {
529
+			$donors = new Give_Donors_Query($args);
530 530
 			$count  = $donors->get_donors();
531 531
 
532
-			Give_Cache::set_group( $cache_key, $count, 'donors', 3600 );
532
+			Give_Cache::set_group($cache_key, $count, 'donors', 3600);
533 533
 		}
534 534
 
535
-		return absint( $count );
535
+		return absint($count);
536 536
 
537 537
 	}
538 538
 
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 	 */
547 547
 	public function create_table() {
548 548
 
549
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
549
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
550 550
 
551
-		$sql = "CREATE TABLE " . $this->table_name . " (
551
+		$sql = "CREATE TABLE ".$this->table_name." (
552 552
 		id bigint(20) NOT NULL AUTO_INCREMENT,
553 553
 		user_id bigint(20) NOT NULL,
554 554
 		email varchar(255) NOT NULL,
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
 		KEY user (user_id)
567 567
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
568 568
 
569
-		dbDelta( $sql );
569
+		dbDelta($sql);
570 570
 
571
-		update_option( $this->table_name . '_db_version', $this->version, false );
571
+		update_option($this->table_name.'_db_version', $this->version, false);
572 572
 	}
573 573
 
574 574
 	/**
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
 		global $wpdb;
584 584
 
585 585
 		if (
586
-			! give_has_upgrade_completed( 'v20_rename_donor_tables' ) &&
587
-			$wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) )
586
+			! give_has_upgrade_completed('v20_rename_donor_tables') &&
587
+			$wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))
588 588
 		) {
589 589
 			$wpdb->donors = $this->table_name = "{$wpdb->prefix}give_customers";
590 590
 		}
@@ -598,41 +598,41 @@  discard block
 block discarded – undo
598 598
 	 *
599 599
 	 * @param $args
600 600
 	 */
601
-	private function bc_1814_params( &$args ) {
601
+	private function bc_1814_params(&$args) {
602 602
 		// Backward compatibility: user_id
603
-		if ( ! empty( $args['user_id'] ) ) {
603
+		if ( ! empty($args['user_id'])) {
604 604
 			$args['user'] = $args['user_id'];
605 605
 		}
606 606
 
607 607
 		// Backward compatibility: id
608
-		if ( ! empty( $args['id'] ) ) {
608
+		if ( ! empty($args['id'])) {
609 609
 			$args['donor'] = $args['id'];
610 610
 		}
611 611
 
612 612
 		// Backward compatibility: name
613
-		if ( ! empty( $args['name'] ) ) {
613
+		if ( ! empty($args['name'])) {
614 614
 			$args['s'] = "name:{$args['name']}";
615 615
 		}
616 616
 
617 617
 		// Backward compatibility: date
618 618
 		// Donors created for a specific date or in a date range.
619
-		if ( ! empty( $args['date'] ) ) {
619
+		if ( ! empty($args['date'])) {
620 620
 
621
-			if ( is_array( $args['date'] ) ) {
621
+			if (is_array($args['date'])) {
622 622
 
623
-				if ( ! empty( $args['date']['start'] ) ) {
624
-					$args['date_query']['after'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
623
+				if ( ! empty($args['date']['start'])) {
624
+					$args['date_query']['after'] = date('Y-m-d H:i:s', strtotime($args['date']['start']));
625 625
 				}
626 626
 
627
-				if ( ! empty( $args['date']['end'] ) ) {
628
-					$args['date_query']['before'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
627
+				if ( ! empty($args['date']['end'])) {
628
+					$args['date_query']['before'] = date('Y-m-d H:i:s', strtotime($args['date']['end']));
629 629
 				}
630 630
 
631 631
 			} else {
632 632
 
633
-				$args['date_query']['year']  = date( 'Y', strtotime( $args['date'] ) );
634
-				$args['date_query']['month'] = date( 'm', strtotime( $args['date'] ) );
635
-				$args['date_query']['day']   = date( 'd', strtotime( $args['date'] ) );
633
+				$args['date_query']['year']  = date('Y', strtotime($args['date']));
634
+				$args['date_query']['month'] = date('m', strtotime($args['date']));
635
+				$args['date_query']['day']   = date('d', strtotime($args['date']));
636 636
 			}
637 637
 		}
638 638
 	}
Please login to merge, or discard this patch.
includes/class-give-logging.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -512,7 +512,7 @@
 block discarded – undo
512 512
 	 * @since  1.7
513 513
 	 * @access public
514 514
 	 *
515
-	 * @return bool
515
+	 * @return false|null
516 516
 	 */
517 517
 	public function delete_cache() {
518 518
 		// Add log related keys to delete.
Please login to merge, or discard this patch.
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 		 * Setup properties
54 54
 		 */
55 55
 
56
-		require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs.php';
57
-		require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs-meta.php';
56
+		require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs.php';
57
+		require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs-meta.php';
58 58
 		$this->log_db     = new Give_DB_Logs();
59 59
 		$this->logmeta_db = new Give_DB_Log_Meta();
60 60
 
@@ -62,22 +62,22 @@  discard block
 block discarded – undo
62 62
 		 * Setup hooks.
63 63
 		 */
64 64
 
65
-		add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache' ) );
66
-		add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache' ) );
67
-		add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache' ) );
68
-		add_action( 'give_delete_log_cache', array( $this, 'delete_cache' ) );
69
-		add_action( 'update_log_metadata', array( $this, 'bc_200_set_payment_as_log_parent' ), 10, 4 );
65
+		add_action('save_post_give_payment', array($this, 'background_process_delete_cache'));
66
+		add_action('save_post_give_forms', array($this, 'background_process_delete_cache'));
67
+		add_action('save_post_give_log', array($this, 'background_process_delete_cache'));
68
+		add_action('give_delete_log_cache', array($this, 'delete_cache'));
69
+		add_action('update_log_metadata', array($this, 'bc_200_set_payment_as_log_parent'), 10, 4);
70 70
 
71 71
 		// Backward compatibility.
72
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
72
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
73 73
 			// Create the log post type
74
-			add_action( 'init', array( $this, 'register_post_type' ), -2 );
74
+			add_action('init', array($this, 'register_post_type'), -2);
75 75
 		}
76 76
 
77 77
 		// Create types taxonomy and default types
78 78
 		// @todo: remove this taxonomy, some addon use this taxonomy with there custom log post type for example: recurring
79 79
 		// Do not use this taxonomy with your log type because we will remove it in future releases.
80
-		add_action( 'init', array( $this, 'register_taxonomy' ), -2 );
80
+		add_action('init', array($this, 'register_taxonomy'), -2);
81 81
 	}
82 82
 
83 83
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		/* Logs post type */
96 96
 		$log_args = array(
97 97
 			'labels'              => array(
98
-				'name' => esc_html__( 'Logs', 'give' ),
98
+				'name' => esc_html__('Logs', 'give'),
99 99
 			),
100 100
 			'public'              => false,
101 101
 			'exclude_from_search' => true,
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 			'query_var'           => false,
105 105
 			'rewrite'             => false,
106 106
 			'capability_type'     => 'post',
107
-			'supports'            => array( 'title', 'editor' ),
107
+			'supports'            => array('title', 'editor'),
108 108
 			'can_export'          => true,
109 109
 		);
110 110
 
111
-		register_post_type( 'give_log', $log_args );
111
+		register_post_type('give_log', $log_args);
112 112
 	}
113 113
 
114 114
 	/**
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 * @return void
123 123
 	 */
124 124
 	public function register_taxonomy() {
125
-		register_taxonomy( 'give_log_type', 'give_log', array(
125
+		register_taxonomy('give_log_type', 'give_log', array(
126 126
 			'public' => false,
127
-		) );
127
+		));
128 128
 	}
129 129
 
130 130
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			'update',
146 146
 		);
147 147
 
148
-		return apply_filters( 'give_log_types', $terms );
148
+		return apply_filters('give_log_types', $terms);
149 149
 	}
150 150
 
151 151
 	/**
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return bool         Whether log type is valid.
162 162
 	 */
163
-	public function valid_type( $type ) {
164
-		return in_array( $type, $this->log_types() );
163
+	public function valid_type($type) {
164
+		return in_array($type, $this->log_types());
165 165
 	}
166 166
 
167 167
 	/**
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return int             Log ID.
182 182
 	 */
183
-	public function add( $title = '', $message = '', $parent = 0, $type = '' ) {
183
+	public function add($title = '', $message = '', $parent = 0, $type = '') {
184 184
 		$log_data = array(
185 185
 			'post_title'   => $title,
186 186
 			'post_content' => $message,
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 			'log_type'     => $type,
189 189
 		);
190 190
 
191
-		return $this->insert_log( $log_data );
191
+		return $this->insert_log($log_data);
192 192
 	}
193 193
 
194 194
 	/**
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @return array             An array of the connected logs.
207 207
 	 */
208
-	public function get_logs( $object_id = 0, $type = '', $paged = null ) {
209
-		return $this->get_connected_logs( array(
208
+	public function get_logs($object_id = 0, $type = '', $paged = null) {
209
+		return $this->get_connected_logs(array(
210 210
 			'log_parent' => $object_id,
211 211
 			'paged'      => $paged,
212 212
 			'log_type'   => $type,
213
-		) );
213
+		));
214 214
 	}
215 215
 
216 216
 	/**
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 *
225 225
 	 * @return int             The ID of the newly created log item.
226 226
 	 */
227
-	public function insert_log( $log_data = array(), $log_meta = array() ) {
227
+	public function insert_log($log_data = array(), $log_meta = array()) {
228 228
 		$log_id = 0;
229 229
 
230 230
 		$defaults = array(
@@ -237,28 +237,28 @@  discard block
 block discarded – undo
237 237
 			'post_status' => 'publish',
238 238
 		);
239 239
 
240
-		$args = wp_parse_args( $log_data, $defaults );
241
-		$this->bc_200_validate_params( $args, $log_meta );
240
+		$args = wp_parse_args($log_data, $defaults);
241
+		$this->bc_200_validate_params($args, $log_meta);
242 242
 
243
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
243
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
244 244
 			global $wpdb;
245 245
 
246 246
 			// Backward Compatibility.
247
-			if ( ! $wpdb->get_var( "SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1" ) ) {
248
-				$latest_log_id = $wpdb->get_var( "SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1" );
249
-				$latest_log_id = empty( $latest_log_id ) ? 1 : ++ $latest_log_id;
247
+			if ( ! $wpdb->get_var("SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1")) {
248
+				$latest_log_id = $wpdb->get_var("SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1");
249
+				$latest_log_id = empty($latest_log_id) ? 1 : ++ $latest_log_id;
250 250
 
251 251
 				$args['ID'] = $latest_log_id;
252
-				$this->log_db->insert( $args );
252
+				$this->log_db->insert($args);
253 253
 			}
254 254
 		}
255 255
 
256
-		$log_id = $this->log_db->add( $args );
256
+		$log_id = $this->log_db->add($args);
257 257
 
258 258
 		// Set log meta, if any
259
-		if ( $log_id && ! empty( $log_meta ) ) {
260
-			foreach ( (array) $log_meta as $key => $meta ) {
261
-				$this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
259
+		if ($log_id && ! empty($log_meta)) {
260
+			foreach ((array) $log_meta as $key => $meta) {
261
+				$this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
262 262
 			}
263 263
 		}
264 264
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return bool|null       True if successful, false otherwise.
282 282
 	 */
283
-	public function update_log( $log_data = array(), $log_meta = array() ) {
283
+	public function update_log($log_data = array(), $log_meta = array()) {
284 284
 		$log_id = 0;
285 285
 
286 286
 		/**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 		 * @param array $log_data Log entry data.
292 292
 		 * @param array $log_meta Log entry meta.
293 293
 		 */
294
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
294
+		do_action('give_pre_update_log', $log_data, $log_meta);
295 295
 
296 296
 		$defaults = array(
297 297
 			'log_parent'  => 0,
@@ -301,28 +301,28 @@  discard block
 block discarded – undo
301 301
 			'post_status' => 'publish',
302 302
 		);
303 303
 
304
-		$args = wp_parse_args( $log_data, $defaults );
305
-		$this->bc_200_validate_params( $args, $log_meta );
304
+		$args = wp_parse_args($log_data, $defaults);
305
+		$this->bc_200_validate_params($args, $log_meta);
306 306
 
307 307
 		// Store the log entry
308
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
308
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
309 309
 			// Backward compatibility.
310
-			$log_id = wp_update_post( $args );
310
+			$log_id = wp_update_post($args);
311 311
 
312
-			if ( $log_id && ! empty( $log_meta ) ) {
313
-				foreach ( (array) $log_meta as $key => $meta ) {
314
-					if ( ! empty( $meta ) ) {
315
-						give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
312
+			if ($log_id && ! empty($log_meta)) {
313
+				foreach ((array) $log_meta as $key => $meta) {
314
+					if ( ! empty($meta)) {
315
+						give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
316 316
 					}
317 317
 				}
318 318
 			}
319 319
 		} else {
320
-			$log_id = $this->log_db->add( $args );
320
+			$log_id = $this->log_db->add($args);
321 321
 
322
-			if ( $log_id && ! empty( $log_meta ) ) {
323
-				foreach ( (array) $log_meta as $key => $meta ) {
324
-					if ( ! empty( $meta ) ) {
325
-						$this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
322
+			if ($log_id && ! empty($log_meta)) {
323
+				foreach ((array) $log_meta as $key => $meta) {
324
+					if ( ! empty($meta)) {
325
+						$this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
326 326
 					}
327 327
 				}
328 328
 			}
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		 * @param array $log_data Log entry data.
338 338
 		 * @param array $log_meta Log entry meta.
339 339
 		 */
340
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
340
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
341 341
 	}
342 342
 
343 343
 	/**
@@ -354,30 +354,30 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @return array|false Array if logs were found, false otherwise.
356 356
 	 */
357
-	public function get_connected_logs( $args = array() ) {
357
+	public function get_connected_logs($args = array()) {
358 358
 		$logs = array();
359 359
 
360
-		$defaults   = array(
360
+		$defaults = array(
361 361
 			'number'      => 20,
362
-			'paged'       => get_query_var( 'paged' ),
362
+			'paged'       => get_query_var('paged'),
363 363
 			'log_type'    => false,
364 364
 
365 365
 			// Backward compatibility.
366 366
 			'post_type'   => 'give_log',
367 367
 			'post_status' => 'publish',
368 368
 		);
369
-		$query_args = wp_parse_args( $args, $defaults );
370
-		$this->bc_200_validate_params( $query_args );
369
+		$query_args = wp_parse_args($args, $defaults);
370
+		$this->bc_200_validate_params($query_args);
371 371
 
372
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
372
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
373 373
 			// Backward compatibility.
374
-			$logs = get_posts( $query_args );
375
-			$this->bc_200_add_new_properties( $logs );
374
+			$logs = get_posts($query_args);
375
+			$this->bc_200_add_new_properties($logs);
376 376
 		} else {
377
-			$logs = $this->log_db->get_logs( $query_args );
377
+			$logs = $this->log_db->get_logs($query_args);
378 378
 		}
379 379
 
380
-		return ( ! empty( $logs ) ? $logs : false );
380
+		return ( ! empty($logs) ? $logs : false);
381 381
 	}
382 382
 
383 383
 	/**
@@ -395,41 +395,41 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return int                Log count.
397 397
 	 */
398
-	public function get_log_count( $object_id = 0, $type = '', $meta_query = null, $date_query = null ) {
398
+	public function get_log_count($object_id = 0, $type = '', $meta_query = null, $date_query = null) {
399 399
 		$logs_count = 0;
400 400
 
401 401
 		$query_args = array(
402
-			'number'      => - 1,
402
+			'number'      => -1,
403 403
 
404 404
 			// Backward comatibility.
405 405
 			'post_type'   => 'give_log',
406 406
 			'post_status' => 'publish',
407 407
 		);
408 408
 
409
-		if ( $object_id ) {
409
+		if ($object_id) {
410 410
 			$query_args['log_parent'] = $object_id;
411 411
 		}
412 412
 
413
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
413
+		if ( ! empty($type) && $this->valid_type($type)) {
414 414
 			$query_args['log_type'] = $type;
415 415
 		}
416 416
 
417
-		if ( ! empty( $meta_query ) ) {
417
+		if ( ! empty($meta_query)) {
418 418
 			$query_args['meta_query'] = $meta_query;
419 419
 		}
420 420
 
421
-		if ( ! empty( $date_query ) ) {
421
+		if ( ! empty($date_query)) {
422 422
 			$query_args['date_query'] = $date_query;
423 423
 		}
424 424
 
425
-		$this->bc_200_validate_params( $query_args );
425
+		$this->bc_200_validate_params($query_args);
426 426
 
427
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
427
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
428 428
 			// Backward compatibility.
429
-			$logs       = new WP_Query( $query_args );
429
+			$logs       = new WP_Query($query_args);
430 430
 			$logs_count = (int) $logs->post_count;
431 431
 		} else {
432
-			$logs_count = $this->log_db->count( $query_args );
432
+			$logs_count = $this->log_db->count($query_args);
433 433
 		}
434 434
 
435 435
 		return $logs_count;
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
 	 *
450 450
 	 * @return void
451 451
 	 */
452
-	public function delete_logs( $object_id = 0, $type = '', $meta_query = null ) {
452
+	public function delete_logs($object_id = 0, $type = '', $meta_query = null) {
453 453
 		$query_args = array(
454 454
 			'log_parent'  => $object_id,
455
-			'number'      => - 1,
455
+			'number'      => -1,
456 456
 			'fields'      => 'ID',
457 457
 
458 458
 			// Backward compatibility.
@@ -460,32 +460,32 @@  discard block
 block discarded – undo
460 460
 			'post_status' => 'publish',
461 461
 		);
462 462
 
463
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
463
+		if ( ! empty($type) && $this->valid_type($type)) {
464 464
 			$query_args['log_type'] = $type;
465 465
 		}
466 466
 
467
-		if ( ! empty( $meta_query ) ) {
467
+		if ( ! empty($meta_query)) {
468 468
 			$query_args['meta_query'] = $meta_query;
469 469
 		}
470 470
 
471
-		$this->bc_200_validate_params( $query_args );
471
+		$this->bc_200_validate_params($query_args);
472 472
 
473
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
473
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
474 474
 			// Backward compatibility.
475
-			$logs = get_posts( $query_args );
475
+			$logs = get_posts($query_args);
476 476
 
477
-			if ( $logs ) {
478
-				foreach ( $logs as $log ) {
479
-					wp_delete_post( $log, true );
477
+			if ($logs) {
478
+				foreach ($logs as $log) {
479
+					wp_delete_post($log, true);
480 480
 				}
481 481
 			}
482 482
 		} else {
483
-			$logs = $this->log_db->get_logs( $query_args );
483
+			$logs = $this->log_db->get_logs($query_args);
484 484
 
485
-			if ( $logs ) {
486
-				foreach ( $logs as $log ) {
487
-					if ( $this->log_db->delete( $log->ID ) ) {
488
-						$this->logmeta_db->delete_row( $log->ID );
485
+			if ($logs) {
486
+				foreach ($logs as $log) {
487
+					if ($this->log_db->delete($log->ID)) {
488
+						$this->logmeta_db->delete_row($log->ID);
489 489
 					}
490 490
 				}
491 491
 			}
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 	 *
503 503
 	 * @param int $post_id
504 504
 	 */
505
-	public function background_process_delete_cache( $post_id ) {
505
+	public function background_process_delete_cache($post_id) {
506 506
 		// Delete log cache immediately
507
-		wp_schedule_single_event( time() - 5, 'give_delete_log_cache' );
507
+		wp_schedule_single_event(time() - 5, 'give_delete_log_cache');
508 508
 	}
509 509
 
510 510
 	/**
@@ -517,17 +517,17 @@  discard block
 block discarded – undo
517 517
 	 */
518 518
 	public function delete_cache() {
519 519
 		// Add log related keys to delete.
520
-		$cache_give_logs      = Give_Cache::get_options_like( 'give_logs' );
521
-		$cache_give_log_count = Give_Cache::get_options_like( 'log_count' );
520
+		$cache_give_logs      = Give_Cache::get_options_like('give_logs');
521
+		$cache_give_log_count = Give_Cache::get_options_like('log_count');
522 522
 
523
-		$cache_option_names = array_merge( $cache_give_logs, $cache_give_log_count );
523
+		$cache_option_names = array_merge($cache_give_logs, $cache_give_log_count);
524 524
 
525 525
 		// Bailout.
526
-		if ( empty( $cache_option_names ) ) {
526
+		if (empty($cache_option_names)) {
527 527
 			return false;
528 528
 		}
529 529
 
530
-		Give_Cache::delete( $cache_option_names );
530
+		Give_Cache::delete($cache_option_names);
531 531
 	}
532 532
 
533 533
 	/**
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 	 * @param array $log_query
540 540
 	 * @param array $log_meta
541 541
 	 */
542
-	private function bc_200_validate_params( &$log_query, &$log_meta = array() ) {
542
+	private function bc_200_validate_params(&$log_query, &$log_meta = array()) {
543 543
 		$query_params = array(
544 544
 			'log_title'    => 'post_title',
545 545
 			'log_parent'   => 'post_parent',
@@ -551,41 +551,41 @@  discard block
 block discarded – undo
551 551
 			'meta_query'   => 'meta_query',
552 552
 		);
553 553
 
554
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
554
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
555 555
 			// Set old params.
556
-			foreach ( $query_params as $new_query_param => $old_query_param ) {
556
+			foreach ($query_params as $new_query_param => $old_query_param) {
557 557
 
558
-				if ( isset( $log_query[ $old_query_param ] ) && empty( $log_query[ $new_query_param ] ) ) {
559
-					$log_query[ $new_query_param ] = $log_query[ $old_query_param ];
558
+				if (isset($log_query[$old_query_param]) && empty($log_query[$new_query_param])) {
559
+					$log_query[$new_query_param] = $log_query[$old_query_param];
560 560
 					continue;
561
-				} elseif ( ! isset( $log_query[ $new_query_param ] ) ) {
561
+				} elseif ( ! isset($log_query[$new_query_param])) {
562 562
 					continue;
563
-				} elseif( empty( $log_query[ $new_query_param ] ) ) {
563
+				} elseif (empty($log_query[$new_query_param])) {
564 564
 					continue;
565 565
 				}
566 566
 
567
-				switch ( $new_query_param ) {
567
+				switch ($new_query_param) {
568 568
 					case 'log_type':
569 569
 						$log_query['tax_query'] = array(
570 570
 							array(
571 571
 								'taxonomy' => 'give_log_type',
572 572
 								'field'    => 'slug',
573
-								'terms'    => $log_query[ $new_query_param ],
573
+								'terms'    => $log_query[$new_query_param],
574 574
 							),
575 575
 						);
576 576
 						break;
577 577
 
578 578
 					case 'meta_query':
579
-						if( ! empty( $log_query['meta_query'] ) && empty( $log_query['post_parent'] ) ) {
580
-							foreach ( $log_query['meta_query'] as $index => $meta_query ){
581
-								if( ! is_array( $meta_query ) || empty( $meta_query['key'] ) ) {
579
+						if ( ! empty($log_query['meta_query']) && empty($log_query['post_parent'])) {
580
+							foreach ($log_query['meta_query'] as $index => $meta_query) {
581
+								if ( ! is_array($meta_query) || empty($meta_query['key'])) {
582 582
 									continue;
583 583
 								}
584 584
 
585
-								switch ( $meta_query['key'] ) {
585
+								switch ($meta_query['key']) {
586 586
 									case '_give_log_form_id':
587 587
 										$log_query['post_parent'] = $meta_query['value'];
588
-										unset( $log_query['meta_query'][$index] );
588
+										unset($log_query['meta_query'][$index]);
589 589
 										break;
590 590
 								}
591 591
 							}
@@ -593,40 +593,40 @@  discard block
 block discarded – undo
593 593
 						break;
594 594
 
595 595
 					default:
596
-						switch( $new_query_param ){
596
+						switch ($new_query_param) {
597 597
 							case 'log_parent':
598 598
 								$log_query['meta_query'][] = array(
599 599
 									'key' => '_give_log_payment_id',
600
-									'value' => $log_query[ $new_query_param ]
600
+									'value' => $log_query[$new_query_param]
601 601
 								);
602 602
 
603 603
 								break;
604 604
 
605 605
 							default:
606
-								$log_query[ $old_query_param ] = $log_query[ $new_query_param ];
606
+								$log_query[$old_query_param] = $log_query[$new_query_param];
607 607
 						}
608 608
 				}
609 609
 			}
610 610
 		} else {
611 611
 			// Set only old params.
612
-			$query_params = array_flip( $query_params );
613
-			foreach ( $query_params as $old_query_param => $new_query_param ) {
614
-				if ( isset( $log_query[ $new_query_param ] ) && empty( $log_query[ $old_query_param ] ) ) {
615
-					$log_query[ $old_query_param ] = $log_query[ $new_query_param ];
612
+			$query_params = array_flip($query_params);
613
+			foreach ($query_params as $old_query_param => $new_query_param) {
614
+				if (isset($log_query[$new_query_param]) && empty($log_query[$old_query_param])) {
615
+					$log_query[$old_query_param] = $log_query[$new_query_param];
616 616
 					continue;
617
-				} elseif ( ! isset( $log_query[ $old_query_param ] ) ) {
617
+				} elseif ( ! isset($log_query[$old_query_param])) {
618 618
 					continue;
619 619
 				}
620 620
 
621
-				switch ( $old_query_param ) {
621
+				switch ($old_query_param) {
622 622
 					case 'tax_query':
623
-						if ( isset( $log_query[ $old_query_param ][0]['terms'] ) ) {
624
-							$log_query[ $new_query_param ] = $log_query[ $old_query_param ][0]['terms'];
623
+						if (isset($log_query[$old_query_param][0]['terms'])) {
624
+							$log_query[$new_query_param] = $log_query[$old_query_param][0]['terms'];
625 625
 						}
626 626
 						break;
627 627
 
628 628
 					default:
629
-						$log_query[ $new_query_param ] = $log_query[ $old_query_param ];
629
+						$log_query[$new_query_param] = $log_query[$old_query_param];
630 630
 				}
631 631
 			}
632 632
 		}
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 *
641 641
 	 * @param  array $logs
642 642
 	 */
643
-	private function bc_200_add_new_properties( &$logs ) {
644
-		if ( empty( $logs ) ) {
643
+	private function bc_200_add_new_properties(&$logs) {
644
+		if (empty($logs)) {
645 645
 			return;
646 646
 		}
647 647
 
@@ -654,30 +654,30 @@  discard block
 block discarded – undo
654 654
 			'log_type'     => 'give_log_type',
655 655
 		);
656 656
 
657
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
658
-			foreach ( $logs as $index => $log ) {
659
-				foreach ( $query_params as $new_query_param => $old_query_param ) {
660
-					if ( ! property_exists( $log, $old_query_param ) ) {
657
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
658
+			foreach ($logs as $index => $log) {
659
+				foreach ($query_params as $new_query_param => $old_query_param) {
660
+					if ( ! property_exists($log, $old_query_param)) {
661 661
 						/**
662 662
 						 *  Set unmatched properties.
663 663
 						 */
664 664
 
665 665
 						// 1. log_type
666
-						$term = get_the_terms( $log->ID, 'give_log_type' );
667
-						$term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array();
666
+						$term = get_the_terms($log->ID, 'give_log_type');
667
+						$term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array();
668 668
 
669
-						$logs[ $index ]->{$new_query_param} = ! empty( $term ) ? $term->slug : '';
669
+						$logs[$index]->{$new_query_param} = ! empty($term) ? $term->slug : '';
670 670
 
671 671
 						continue;
672 672
 					}
673 673
 
674
-					switch ( $old_query_param ) {
674
+					switch ($old_query_param) {
675 675
 						case 'post_parent':
676
-							$logs[ $index ]->{$new_query_param} = give_get_meta( $log->ID, '_give_log_payment_id', true );
676
+							$logs[$index]->{$new_query_param} = give_get_meta($log->ID, '_give_log_payment_id', true);
677 677
 							break;
678 678
 
679 679
 						default:
680
-							$logs[ $index ]->{$new_query_param} = $log->{$old_query_param};
680
+							$logs[$index]->{$new_query_param} = $log->{$old_query_param};
681 681
 					}
682 682
 				}
683 683
 			}
@@ -697,10 +697,10 @@  discard block
 block discarded – undo
697 697
 	 *
698 698
 	 * @return mixed
699 699
 	 */
700
-	public function bc_200_set_payment_as_log_parent( $check, $log_id, $meta_key, $meta_value ) {
700
+	public function bc_200_set_payment_as_log_parent($check, $log_id, $meta_key, $meta_value) {
701 701
 		global $wpdb;
702 702
 		$update_status = false;
703
-		$post_type     = get_post_type( $log_id );
703
+		$post_type     = get_post_type($log_id);
704 704
 
705 705
 		// Bailout.
706 706
 		if (
@@ -720,9 +720,9 @@  discard block
 block discarded – undo
720 720
 			)
721 721
 		);
722 722
 
723
-		if ( $form_id ) {
724
-			$this->logmeta_db->delete_meta( $log_id, '_give_log_payment_id' );
725
-			$this->logmeta_db->update_meta( $log_id, '_give_log_form_id', $form_id );
723
+		if ($form_id) {
724
+			$this->logmeta_db->delete_meta($log_id, '_give_log_payment_id');
725
+			$this->logmeta_db->update_meta($log_id, '_give_log_form_id', $form_id);
726 726
 
727 727
 			$update_status = $wpdb->update(
728 728
 				$this->log_db->table_name,
Please login to merge, or discard this patch.
includes/install.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -397,7 +397,7 @@
 block discarded – undo
397 397
  *
398 398
  * @since 1.8.11
399 399
  *
400
- * @return void
400
+ * @return false|null
401 401
  */
402 402
 function give_create_pages() {
403 403
 
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
  * @global     $wpdb
29 29
  * @return void
30 30
  */
31
-function give_install( $network_wide = false ) {
31
+function give_install($network_wide = false) {
32 32
 
33 33
 	global $wpdb;
34 34
 
35
-	if ( is_multisite() && $network_wide ) {
35
+	if (is_multisite() && $network_wide) {
36 36
 
37
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
37
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
38 38
 
39
-			switch_to_blog( $blog_id );
39
+			switch_to_blog($blog_id);
40 40
 			give_run_install();
41 41
 			restore_current_blog();
42 42
 
@@ -63,31 +63,31 @@  discard block
 block discarded – undo
63 63
 	give_setup_post_types();
64 64
 
65 65
 	// Add Upgraded From Option.
66
-	$current_version = get_option( 'give_version' );
67
-	if ( $current_version ) {
68
-		update_option( 'give_version_upgraded_from', $current_version, false );
66
+	$current_version = get_option('give_version');
67
+	if ($current_version) {
68
+		update_option('give_version_upgraded_from', $current_version, false);
69 69
 	}
70 70
 
71 71
 	// Setup some default options.
72 72
 	$options = array();
73 73
 
74 74
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
75
-	if ( empty( $current_version ) ) {
76
-		$options = array_merge( $options, give_get_default_settings() );
75
+	if (empty($current_version)) {
76
+		$options = array_merge($options, give_get_default_settings());
77 77
 	}
78 78
 
79 79
 	// Populate the default values.
80
-	update_option( 'give_settings', array_merge( $give_options, $options ), false );
80
+	update_option('give_settings', array_merge($give_options, $options), false);
81 81
 
82 82
 	/**
83 83
 	 * Run plugin upgrades.
84 84
 	 *
85 85
 	 * @since 1.8
86 86
 	 */
87
-	do_action( 'give_upgrades' );
87
+	do_action('give_upgrades');
88 88
 
89
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
90
-		update_option( 'give_version', GIVE_VERSION, false );
89
+	if (GIVE_VERSION !== get_option('give_version')) {
90
+		update_option('give_version', GIVE_VERSION, false);
91 91
 	}
92 92
 
93 93
 	// Create Give roles.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	// Set api version, end point and refresh permalink.
99 99
 	$api = new Give_API();
100 100
 	$api->add_endpoint();
101
-	update_option( 'give_default_api_version', 'v' . $api->get_version(), false );
101
+	update_option('give_default_api_version', 'v'.$api->get_version(), false);
102 102
 
103 103
 	flush_rewrite_rules();
104 104
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	$donor_meta->create_table();
110 110
 
111 111
 	// Add a temporary option to note that Give pages have been created.
112
-	Give_Cache::set( '_give_installed', $options, 30, true );
112
+	Give_Cache::set('_give_installed', $options, 30, true);
113 113
 
114
-	if ( ! $current_version ) {
114
+	if ( ! $current_version) {
115 115
 
116
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
116
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
117 117
 
118 118
 		// When new upgrade routines are added, mark them as complete on fresh install.
119 119
 		$upgrade_routines = array(
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 			'v224_update_donor_meta'
150 150
 		);
151 151
 
152
-		foreach ( $upgrade_routines as $upgrade ) {
153
-			give_set_upgrade_complete( $upgrade );
152
+		foreach ($upgrade_routines as $upgrade) {
153
+			give_set_upgrade_complete($upgrade);
154 154
 		}
155 155
 	}
156 156
 
157 157
 	// Bail if activating from network, or bulk.
158
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
158
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
159 159
 		return;
160 160
 	}
161 161
 
162 162
 	// Add the transient to redirect.
163
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
163
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
164 164
 }
165 165
 
166 166
 /**
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
  * @param  int    $site_id The Site ID.
179 179
  * @param  array  $meta    Blog Meta.
180 180
  */
181
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
181
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
182 182
 
183
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
183
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
184 184
 
185
-		switch_to_blog( $blog_id );
185
+		switch_to_blog($blog_id);
186 186
 		give_install();
187 187
 		restore_current_blog();
188 188
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
 }
192 192
 
193
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
193
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
194 194
 
195 195
 
196 196
 /**
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
  *
204 204
  * @return array          The tables to drop.
205 205
  */
206
-function give_wpmu_drop_tables( $tables, $blog_id ) {
206
+function give_wpmu_drop_tables($tables, $blog_id) {
207 207
 
208
-	switch_to_blog( $blog_id );
208
+	switch_to_blog($blog_id);
209 209
 	$donors_db     = new Give_DB_Donors();
210 210
 	$donor_meta_db = new Give_DB_Donor_Meta();
211 211
 
212
-	if ( $donors_db->installed() ) {
212
+	if ($donors_db->installed()) {
213 213
 		$tables[] = $donors_db->table_name;
214 214
 		$tables[] = $donor_meta_db->table_name;
215 215
 	}
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
 }
221 221
 
222
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
222
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
223 223
 
224 224
 /**
225 225
  * Post-installation
@@ -231,16 +231,16 @@  discard block
 block discarded – undo
231 231
  */
232 232
 function give_after_install() {
233 233
 
234
-	if ( ! is_admin() ) {
234
+	if ( ! is_admin()) {
235 235
 		return;
236 236
 	}
237 237
 
238
-	$give_options     = Give_Cache::get( '_give_installed', true );
239
-	$give_table_check = get_option( '_give_table_check', false );
238
+	$give_options     = Give_Cache::get('_give_installed', true);
239
+	$give_table_check = get_option('_give_table_check', false);
240 240
 
241
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
241
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
242 242
 
243
-		if ( ! @Give()->donor_meta->installed() ) {
243
+		if ( ! @Give()->donor_meta->installed()) {
244 244
 
245 245
 			// Create the donor meta database.
246 246
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 		}
250 250
 
251
-		if ( ! @Give()->donors->installed() ) {
251
+		if ( ! @Give()->donors->installed()) {
252 252
 			// Create the donor database.
253 253
 			// (this ensures it creates it on multisite instances where it is network activated).
254 254
 			@Give()->donors->create_table();
@@ -260,22 +260,22 @@  discard block
 block discarded – undo
260 260
 			 *
261 261
 			 * @param array $give_options Give plugin options.
262 262
 			 */
263
-			do_action( 'give_after_install', $give_options );
263
+			do_action('give_after_install', $give_options);
264 264
 		}
265 265
 
266
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ), false );
266
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS), false);
267 267
 
268 268
 	}
269 269
 
270 270
 	// Delete the transient
271
-	if ( false !== $give_options ) {
272
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
271
+	if (false !== $give_options) {
272
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
273 273
 	}
274 274
 
275 275
 
276 276
 }
277 277
 
278
-add_action( 'admin_init', 'give_after_install' );
278
+add_action('admin_init', 'give_after_install');
279 279
 
280 280
 
281 281
 /**
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 
291 291
 	global $wp_roles;
292 292
 
293
-	if ( ! is_object( $wp_roles ) ) {
293
+	if ( ! is_object($wp_roles)) {
294 294
 		return;
295 295
 	}
296 296
 
297
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
297
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
298 298
 
299 299
 		// Create Give plugin roles
300 300
 		$roles = new Give_Roles();
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
 }
307 307
 
308
-add_action( 'admin_init', 'give_install_roles_on_network' );
308
+add_action('admin_init', 'give_install_roles_on_network');
309 309
 
310 310
 /**
311 311
  * Default core setting values.
@@ -347,14 +347,14 @@  discard block
 block discarded – undo
347 347
 		'uninstall_on_delete'                         => 'disabled',
348 348
 		'the_content_filter'                          => 'enabled',
349 349
 		'scripts_footer'                              => 'disabled',
350
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
350
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
351 351
 		'agreement_text'                              => give_get_default_agreement_text(),
352 352
 
353 353
 		// Paypal IPN verification.
354 354
 		'paypal_verification'                         => 'enabled',
355 355
 
356 356
 		// Default is manual gateway.
357
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
357
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
358 358
 		'default_gateway'                             => 'manual',
359 359
 
360 360
 		// Offline gateway setup.
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
  */
383 383
 function give_get_default_agreement_text() {
384 384
 
385
-	$org_name = get_bloginfo( 'name' );
385
+	$org_name = get_bloginfo('name');
386 386
 
387 387
 	$agreement = sprintf(
388 388
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 		$org_name
397 397
 	);
398 398
 
399
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
399
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
400 400
 }
401 401
 
402 402
 
@@ -410,19 +410,19 @@  discard block
 block discarded – undo
410 410
 function give_create_pages() {
411 411
 
412 412
 	// Bailout if pages already created.
413
-	if ( get_option( 'give_install_pages_created' ) ) {
413
+	if (get_option('give_install_pages_created')) {
414 414
 		return false;
415 415
 	}
416 416
 
417 417
 	$options = array();
418 418
 
419 419
 	// Checks if the Success Page option exists AND that the page exists.
420
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
420
+	if ( ! get_post(give_get_option('success_page'))) {
421 421
 
422 422
 		// Donation Confirmation (Success) Page
423 423
 		$success = wp_insert_post(
424 424
 			array(
425
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
425
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
426 426
 				'post_content'   => '[give_receipt]',
427 427
 				'post_status'    => 'publish',
428 428
 				'post_author'    => 1,
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
 	}
437 437
 
438 438
 	// Checks if the Failure Page option exists AND that the page exists.
439
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
439
+	if ( ! get_post(give_get_option('failure_page'))) {
440 440
 
441 441
 		// Failed Donation Page
442 442
 		$failed = wp_insert_post(
443 443
 			array(
444
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
445
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
444
+				'post_title'     => esc_html__('Donation Failed', 'give'),
445
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
446 446
 				'post_status'    => 'publish',
447 447
 				'post_author'    => 1,
448 448
 				'post_type'      => 'page',
@@ -454,11 +454,11 @@  discard block
 block discarded – undo
454 454
 	}
455 455
 
456 456
 	// Checks if the History Page option exists AND that the page exists.
457
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
457
+	if ( ! get_post(give_get_option('history_page'))) {
458 458
 		// Donation History Page
459 459
 		$history = wp_insert_post(
460 460
 			array(
461
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
461
+				'post_title'     => esc_html__('Donation History', 'give'),
462 462
 				'post_content'   => '[donation_history]',
463 463
 				'post_status'    => 'publish',
464 464
 				'post_author'    => 1,
@@ -470,11 +470,11 @@  discard block
 block discarded – undo
470 470
 		$options['history_page'] = $history;
471 471
 	}
472 472
 
473
-	if ( ! empty( $options ) ) {
474
-		update_option( 'give_settings', array_merge( give_get_settings(), $options ), false );
473
+	if ( ! empty($options)) {
474
+		update_option('give_settings', array_merge(give_get_settings(), $options), false);
475 475
 	}
476 476
 
477
-	add_option( 'give_install_pages_created', 1, '', false );
477
+	add_option('give_install_pages_created', 1, '', false);
478 478
 }
479 479
 
480
-add_action( 'admin_init', 'give_create_pages', - 1 );
480
+add_action('admin_init', 'give_create_pages', - 1);
Please login to merge, or discard this patch.
includes/payments/backward-compatibility.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@
 block discarded – undo
207 207
  *                              metadata entries with the specified value.
208 208
  *                              Otherwise, update all entries.
209 209
  *
210
- * @return mixed
210
+ * @return null|boolean
211 211
  */
212 212
 function _give_20_bc_saving_old_payment_meta( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
213 213
 	// Bailout.
Please login to merge, or discard this patch.
Spacing   +166 added lines, -171 removed lines patch added patch discarded remove patch
@@ -9,74 +9,74 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * @return void
11 11
  */
12
-function _give_20_bc_split_and_save_give_payment_meta( $object_id, $meta_value ) {
12
+function _give_20_bc_split_and_save_give_payment_meta($object_id, $meta_value) {
13 13
 	// Bailout
14
-	if ( empty( $meta_value ) ) {
14
+	if (empty($meta_value)) {
15 15
 		return;
16
-	} elseif ( ! is_array( $meta_value ) ) {
16
+	} elseif ( ! is_array($meta_value)) {
17 17
 		$meta_value = array();
18 18
 	}
19 19
 
20
-	remove_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10 );
20
+	remove_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10);
21 21
 
22 22
 	// Date payment meta.
23
-	if ( ! empty( $meta_value['date'] ) ) {
24
-		give_update_meta( $object_id, '_give_payment_date', $meta_value['date'] );
23
+	if ( ! empty($meta_value['date'])) {
24
+		give_update_meta($object_id, '_give_payment_date', $meta_value['date']);
25 25
 	}
26 26
 
27 27
 	// Currency payment meta.
28
-	if ( ! empty( $meta_value['currency'] ) ) {
29
-		give_update_meta( $object_id, '_give_payment_currency', $meta_value['currency'] );
28
+	if ( ! empty($meta_value['currency'])) {
29
+		give_update_meta($object_id, '_give_payment_currency', $meta_value['currency']);
30 30
 	}
31 31
 
32 32
 	// User information.
33
-	if ( ! empty( $meta_value['user_info'] ) ) {
33
+	if ( ! empty($meta_value['user_info'])) {
34 34
 		// Donor first name.
35
-		if ( ! empty( $meta_value['user_info']['first_name'] ) ) {
36
-			give_update_meta( $object_id, '_give_donor_billing_first_name', $meta_value['user_info']['first_name'] );
35
+		if ( ! empty($meta_value['user_info']['first_name'])) {
36
+			give_update_meta($object_id, '_give_donor_billing_first_name', $meta_value['user_info']['first_name']);
37 37
 		}
38 38
 
39 39
 		// Donor last name.
40
-		if ( ! empty( $meta_value['user_info']['last_name'] ) ) {
41
-			give_update_meta( $object_id, '_give_donor_billing_last_name', $meta_value['user_info']['last_name'] );
40
+		if ( ! empty($meta_value['user_info']['last_name'])) {
41
+			give_update_meta($object_id, '_give_donor_billing_last_name', $meta_value['user_info']['last_name']);
42 42
 		}
43 43
 
44 44
 		// Donor address payment meta.
45
-		if ( ! empty( $meta_value['user_info']['address'] ) ) {
45
+		if ( ! empty($meta_value['user_info']['address'])) {
46 46
 
47 47
 			// Address1.
48
-			if ( ! empty( $meta_value['user_info']['address']['line1'] ) ) {
49
-				give_update_meta( $object_id, '_give_donor_billing_address1', $meta_value['user_info']['address']['line1'] );
48
+			if ( ! empty($meta_value['user_info']['address']['line1'])) {
49
+				give_update_meta($object_id, '_give_donor_billing_address1', $meta_value['user_info']['address']['line1']);
50 50
 			}
51 51
 
52 52
 			// Address2.
53
-			if ( ! empty( $meta_value['user_info']['address']['line2'] ) ) {
54
-				give_update_meta( $object_id, '_give_donor_billing_address2', $meta_value['user_info']['address']['line2'] );
53
+			if ( ! empty($meta_value['user_info']['address']['line2'])) {
54
+				give_update_meta($object_id, '_give_donor_billing_address2', $meta_value['user_info']['address']['line2']);
55 55
 			}
56 56
 
57 57
 			// City.
58
-			if ( ! empty( $meta_value['user_info']['address']['city'] ) ) {
59
-				give_update_meta( $object_id, '_give_donor_billing_city', $meta_value['user_info']['address']['city'] );
58
+			if ( ! empty($meta_value['user_info']['address']['city'])) {
59
+				give_update_meta($object_id, '_give_donor_billing_city', $meta_value['user_info']['address']['city']);
60 60
 			}
61 61
 
62 62
 			// Zip.
63
-			if ( ! empty( $meta_value['user_info']['address']['zip'] ) ) {
64
-				give_update_meta( $object_id, '_give_donor_billing_zip', $meta_value['user_info']['address']['zip'] );
63
+			if ( ! empty($meta_value['user_info']['address']['zip'])) {
64
+				give_update_meta($object_id, '_give_donor_billing_zip', $meta_value['user_info']['address']['zip']);
65 65
 			}
66 66
 
67 67
 			// State.
68
-			if ( ! empty( $meta_value['user_info']['address']['state'] ) ) {
69
-				give_update_meta( $object_id, '_give_donor_billing_state', $meta_value['user_info']['address']['state'] );
68
+			if ( ! empty($meta_value['user_info']['address']['state'])) {
69
+				give_update_meta($object_id, '_give_donor_billing_state', $meta_value['user_info']['address']['state']);
70 70
 			}
71 71
 
72 72
 			// Country.
73
-			if ( ! empty( $meta_value['user_info']['address']['country'] ) ) {
74
-				give_update_meta( $object_id, '_give_donor_billing_country', $meta_value['user_info']['address']['country'] );
73
+			if ( ! empty($meta_value['user_info']['address']['country'])) {
74
+				give_update_meta($object_id, '_give_donor_billing_country', $meta_value['user_info']['address']['country']);
75 75
 			}
76 76
 		}
77 77
 	}// End if().
78 78
 
79
-	add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 );
79
+	add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5);
80 80
 }
81 81
 
82 82
 /**
@@ -89,103 +89,99 @@  discard block
 block discarded – undo
89 89
  *
90 90
  * @return array
91 91
  */
92
-function _give_20_bc_give_payment_meta_value( $object_id, $meta_value ) {
92
+function _give_20_bc_give_payment_meta_value($object_id, $meta_value) {
93 93
 	$cache_key = "_give_payment_meta_{$object_id}";
94
-	$cache     = Give_Cache::get_db_query( $cache_key );
94
+	$cache     = Give_Cache::get_db_query($cache_key);
95 95
 
96
-	if ( ! is_null( $cache ) ) {
96
+	if ( ! is_null($cache)) {
97 97
 		return $cache;
98 98
 	}
99 99
 
100 100
 	// Set default value to array.
101
-	if ( ! is_array( $meta_value ) ) {
101
+	if ( ! is_array($meta_value)) {
102 102
 		$meta_value = array();
103 103
 	}
104 104
 
105 105
 	// Donation key.
106
-	$meta_value['key'] = give_get_meta( $object_id, '_give_payment_purchase_key', true );
106
+	$meta_value['key'] = give_get_meta($object_id, '_give_payment_purchase_key', true);
107 107
 
108 108
 	// Donation form.
109
-	$meta_value['form_title'] = give_get_meta( $object_id, '_give_payment_form_title', true );
109
+	$meta_value['form_title'] = give_get_meta($object_id, '_give_payment_form_title', true);
110 110
 
111 111
 	// Donor email.
112
-	$meta_value['email'] = give_get_meta( $object_id, '_give_payment_donor_email', true );
113
-	$meta_value['email'] = ! empty( $meta_value['email'] ) ?
114
-		$meta_value['email'] :
115
-		Give()->donors->get_column( 'email', give_get_payment_donor_id( $object_id ) );
112
+	$meta_value['email'] = give_get_meta($object_id, '_give_payment_donor_email', true);
113
+	$meta_value['email'] = ! empty($meta_value['email']) ?
114
+		$meta_value['email'] : Give()->donors->get_column('email', give_get_payment_donor_id($object_id));
116 115
 
117 116
 	// Form id.
118
-	$meta_value['form_id'] = give_get_meta( $object_id, '_give_payment_form_id', true );
117
+	$meta_value['form_id'] = give_get_meta($object_id, '_give_payment_form_id', true);
119 118
 
120 119
 	// Price id.
121
-	$meta_value['price_id'] = give_get_meta( $object_id, '_give_payment_price_id', true );
120
+	$meta_value['price_id'] = give_get_meta($object_id, '_give_payment_price_id', true);
122 121
 
123 122
 	// Date.
124
-	$meta_value['date'] = give_get_meta( $object_id, '_give_payment_date', true );
125
-	$meta_value['date'] = ! empty( $meta_value['date'] ) ?
126
-		$meta_value['date'] :
127
-		get_post_field( 'post_date', $object_id );
123
+	$meta_value['date'] = give_get_meta($object_id, '_give_payment_date', true);
124
+	$meta_value['date'] = ! empty($meta_value['date']) ?
125
+		$meta_value['date'] : get_post_field('post_date', $object_id);
128 126
 
129 127
 	// Currency.
130
-	$meta_value['currency'] = give_get_meta( $object_id, '_give_payment_currency', true );
128
+	$meta_value['currency'] = give_get_meta($object_id, '_give_payment_currency', true);
131 129
 
132 130
 	// Decode donor data.
133
-	$donor_names = give_get_donor_name_by( give_get_meta( $object_id, '_give_payment_donor_id', true ), 'donor' );
134
-	$donor_names = explode( ' ', $donor_names, 2 );
131
+	$donor_names = give_get_donor_name_by(give_get_meta($object_id, '_give_payment_donor_id', true), 'donor');
132
+	$donor_names = explode(' ', $donor_names, 2);
135 133
 
136 134
 	// Donor first name.
137
-	$donor_data['first_name'] = give_get_meta( $object_id, '_give_donor_billing_first_name', true );
138
-	$donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ?
139
-		$donor_data['first_name'] :
140
-		$donor_names[0];
135
+	$donor_data['first_name'] = give_get_meta($object_id, '_give_donor_billing_first_name', true);
136
+	$donor_data['first_name'] = ! empty($donor_data['first_name']) ?
137
+		$donor_data['first_name'] : $donor_names[0];
141 138
 
142 139
 	// Donor last name.
143
-	$donor_data['last_name'] = give_get_meta( $object_id, '_give_donor_billing_last_name', true );
144
-	$donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ?
145
-		$donor_data['last_name'] :
146
-		( isset( $donor_names[1] ) ? $donor_names[1] : '' );
140
+	$donor_data['last_name'] = give_get_meta($object_id, '_give_donor_billing_last_name', true);
141
+	$donor_data['last_name'] = ! empty($donor_data['last_name']) ?
142
+		$donor_data['last_name'] : (isset($donor_names[1]) ? $donor_names[1] : '');
147 143
 
148 144
 	// Donor email.
149 145
 	$donor_data['email'] = $meta_value['email'];
150 146
 
151 147
 	// User ID.
152
-	$donor_data['id'] = give_get_payment_user_id( $object_id );
148
+	$donor_data['id'] = give_get_payment_user_id($object_id);
153 149
 
154 150
 	$donor_data['address'] = false;
155 151
 
156 152
 	// Address1.
157
-	if ( $address1 = give_get_meta( $object_id, '_give_donor_billing_address1', true ) ) {
153
+	if ($address1 = give_get_meta($object_id, '_give_donor_billing_address1', true)) {
158 154
 		$donor_data['address']['line1'] = $address1;
159 155
 	}
160 156
 
161 157
 	// Address2.
162
-	if ( $address2 = give_get_meta( $object_id, '_give_donor_billing_address2', true ) ) {
158
+	if ($address2 = give_get_meta($object_id, '_give_donor_billing_address2', true)) {
163 159
 		$donor_data['address']['line2'] = $address2;
164 160
 	}
165 161
 
166 162
 	// City.
167
-	if ( $city = give_get_meta( $object_id, '_give_donor_billing_city', true ) ) {
163
+	if ($city = give_get_meta($object_id, '_give_donor_billing_city', true)) {
168 164
 		$donor_data['address']['city'] = $city;
169 165
 	}
170 166
 
171 167
 	// Zip.
172
-	if ( $zip = give_get_meta( $object_id, '_give_donor_billing_zip', true ) ) {
168
+	if ($zip = give_get_meta($object_id, '_give_donor_billing_zip', true)) {
173 169
 		$donor_data['address']['zip'] = $zip;
174 170
 	}
175 171
 
176 172
 	// State.
177
-	if ( $state = give_get_meta( $object_id, '_give_donor_billing_state', true ) ) {
173
+	if ($state = give_get_meta($object_id, '_give_donor_billing_state', true)) {
178 174
 		$donor_data['address']['state'] = $state;
179 175
 	}
180 176
 
181 177
 	// Country.
182
-	if ( $country = give_get_meta( $object_id, '_give_donor_billing_country', true ) ) {
178
+	if ($country = give_get_meta($object_id, '_give_donor_billing_country', true)) {
183 179
 		$donor_data['address']['country'] = $country;
184 180
 	}
185 181
 
186
-	$meta_value['user_info'] = maybe_unserialize( $donor_data );
182
+	$meta_value['user_info'] = maybe_unserialize($donor_data);
187 183
 
188
-	Give_Cache::set_db_query( $cache_key, $meta_value );
184
+	Give_Cache::set_db_query($cache_key, $meta_value);
189 185
 
190 186
 	return $meta_value;
191 187
 }
@@ -209,37 +205,37 @@  discard block
 block discarded – undo
209 205
  *
210 206
  * @return mixed
211 207
  */
212
-function _give_20_bc_saving_old_payment_meta( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
208
+function _give_20_bc_saving_old_payment_meta($check, $object_id, $meta_key, $meta_value, $prev_value) {
213 209
 	// Bailout.
214 210
 	if (
215
-		'give_payment' !== get_post_type( $object_id ) ||
216
-		! in_array( $meta_key, array(
211
+		'give_payment' !== get_post_type($object_id) ||
212
+		! in_array($meta_key, array(
217 213
 			'_give_payment_meta',
218 214
 			'_give_payment_user_email',
219 215
 			'_give_payment_customer_id',
220 216
 			'give_payment_user_ip',
221
-		) )
217
+		))
222 218
 	) {
223 219
 		return $check;
224 220
 	}
225 221
 
226
-	if ( '_give_payment_meta' === $meta_key ) {
227
-		_give_20_bc_split_and_save_give_payment_meta( $object_id, $meta_value );
228
-	} elseif ( '_give_payment_user_email' === $meta_key ) {
229
-		give_update_meta( $object_id, '_give_payment_donor_email', $meta_value );
222
+	if ('_give_payment_meta' === $meta_key) {
223
+		_give_20_bc_split_and_save_give_payment_meta($object_id, $meta_value);
224
+	} elseif ('_give_payment_user_email' === $meta_key) {
225
+		give_update_meta($object_id, '_give_payment_donor_email', $meta_value);
230 226
 		$check = true;
231
-	} elseif ( '_give_payment_customer_id' === $meta_key ) {
232
-		give_update_meta( $object_id, '_give_payment_donor_id', $meta_value );
227
+	} elseif ('_give_payment_customer_id' === $meta_key) {
228
+		give_update_meta($object_id, '_give_payment_donor_id', $meta_value);
233 229
 		$check = true;
234
-	} elseif ( 'give_payment_user_ip' === $meta_key ) {
235
-		give_update_meta( $object_id, '_give_payment_donor_ip', $meta_value );
230
+	} elseif ('give_payment_user_ip' === $meta_key) {
231
+		give_update_meta($object_id, '_give_payment_donor_ip', $meta_value);
236 232
 		$check = true;
237 233
 	}
238 234
 
239 235
 	return $check;
240 236
 }
241 237
 
242
-add_filter( 'update_post_metadata', '_give_20_bc_saving_old_payment_meta', 10, 5 );
238
+add_filter('update_post_metadata', '_give_20_bc_saving_old_payment_meta', 10, 5);
243 239
 
244 240
 
245 241
 /**
@@ -254,7 +250,7 @@  discard block
 block discarded – undo
254 250
  *
255 251
  * @return mixed
256 252
  */
257
-function _give_20_bc_get_old_payment_meta( $check, $object_id, $meta_key, $single ) {
253
+function _give_20_bc_get_old_payment_meta($check, $object_id, $meta_key, $single) {
258 254
 	global $wpdb;
259 255
 
260 256
 	// Deprecated meta keys.
@@ -265,32 +261,31 @@  discard block
 block discarded – undo
265 261
 	);
266 262
 
267 263
 	// Add _give_payment_meta to backward compatibility
268
-	if ( ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) {
264
+	if ( ! give_has_upgrade_completed('v20_upgrades_payment_metadata')) {
269 265
 		$old_meta_keys[] = '_give_payment_meta';
270 266
 	}
271 267
 
272 268
 	// Bailout.
273 269
 	if (
274
-		'give_payment' !== get_post_type( $object_id ) ||
275
-		! in_array( $meta_key, $old_meta_keys )
270
+		'give_payment' !== get_post_type($object_id) ||
271
+		! in_array($meta_key, $old_meta_keys)
276 272
 	) {
277 273
 		return $check;
278 274
 	}
279 275
 
280 276
 	$cache_key = "{$meta_key}_{$object_id}";
281
-	$check     = Give_Cache::get_db_query( $cache_key );
277
+	$check     = Give_Cache::get_db_query($cache_key);
282 278
 
283
-	if ( is_null( $check ) ) {
284
-		switch ( $meta_key ) {
279
+	if (is_null($check)) {
280
+		switch ($meta_key) {
285 281
 
286 282
 			// Handle old meta keys.
287 283
 			case '_give_payment_meta':
288
-				remove_filter( 'get_post_metadata', '_give_20_bc_get_old_payment_meta' );
284
+				remove_filter('get_post_metadata', '_give_20_bc_get_old_payment_meta');
289 285
 
290 286
 				// if ( $meta_value = give_get_meta( $object_id, '_give_payment_meta' ) ) {
291
-				$meta_value = ! empty( $meta_value ) ?
292
-					current( $meta_value ) :
293
-					(array) maybe_unserialize(
287
+				$meta_value = ! empty($meta_value) ?
288
+					current($meta_value) : (array) maybe_unserialize(
294 289
 						$wpdb->get_var(
295 290
 							$wpdb->prepare(
296 291
 								"
@@ -304,44 +299,44 @@  discard block
 block discarded – undo
304 299
 							)
305 300
 						)
306 301
 					);
307
-				$check      = _give_20_bc_give_payment_meta_value( $object_id, $meta_value );
302
+				$check = _give_20_bc_give_payment_meta_value($object_id, $meta_value);
308 303
 				// }
309 304
 
310
-				add_filter( 'get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5 );
305
+				add_filter('get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5);
311 306
 
312 307
 				break;
313 308
 
314 309
 			case '_give_payment_customer_id':
315
-				if ( $donor_id = give_get_meta( $object_id, '_give_payment_donor_id', $single ) ) {
310
+				if ($donor_id = give_get_meta($object_id, '_give_payment_donor_id', $single)) {
316 311
 					$check = $donor_id;
317 312
 				}
318 313
 				break;
319 314
 
320 315
 			case '_give_payment_user_email':
321
-				if ( $donor_email = give_get_meta( $object_id, '_give_payment_donor_email', $single ) ) {
316
+				if ($donor_email = give_get_meta($object_id, '_give_payment_donor_email', $single)) {
322 317
 					$check = $donor_email;
323 318
 				}
324 319
 				break;
325 320
 
326 321
 			case '_give_payment_user_ip':
327
-				if ( $donor_ip = give_get_meta( $object_id, '_give_payment_donor_ip', $single ) ) {
322
+				if ($donor_ip = give_get_meta($object_id, '_give_payment_donor_ip', $single)) {
328 323
 					$check = $donor_ip;
329 324
 				}
330 325
 				break;
331 326
 		}// End switch().
332 327
 
333
-		Give_Cache::set_db_query( $cache_key, $check );
328
+		Give_Cache::set_db_query($cache_key, $check);
334 329
 	}
335 330
 
336 331
 	// Put result in an array on zero index.
337
-	if ( ! is_null( $check ) ) {
338
-		$check = array( $check );
332
+	if ( ! is_null($check)) {
333
+		$check = array($check);
339 334
 	}
340 335
 
341 336
 	return $check;
342 337
 }
343 338
 
344
-add_filter( 'get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5 );
339
+add_filter('get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5);
345 340
 
346 341
 
347 342
 /**
@@ -356,9 +351,9 @@  discard block
 block discarded – undo
356 351
  *
357 352
  * @return mixed
358 353
  */
359
-function _give_20_bc_get_new_payment_meta( $check, $object_id, $meta_key, $single ) {
354
+function _give_20_bc_get_new_payment_meta($check, $object_id, $meta_key, $single) {
360 355
 	// Bailout: do not apply backward compatibility if upgrade done.
361
-	if ( give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) {
356
+	if (give_has_upgrade_completed('v20_upgrades_payment_metadata')) {
362 357
 		return $check;
363 358
 	}
364 359
 
@@ -380,26 +375,26 @@  discard block
 block discarded – undo
380 375
 	);
381 376
 
382 377
 	// metadata_exists fx will cause of firing get_post_metadata filter again so remove it to prevent infinite loop.
383
-	remove_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta' );
378
+	remove_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta');
384 379
 
385 380
 	// Bailout.
386 381
 	if (
387
-		'give_payment' !== get_post_type( $object_id ) ||
388
-		! in_array( $meta_key, $new_meta_keys ) ||
389
-		metadata_exists( 'post', $object_id, $meta_key )
382
+		'give_payment' !== get_post_type($object_id) ||
383
+		! in_array($meta_key, $new_meta_keys) ||
384
+		metadata_exists('post', $object_id, $meta_key)
390 385
 	) {
391
-		add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 );
386
+		add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5);
392 387
 
393 388
 		return $check;
394 389
 	}
395 390
 
396
-	add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 );
391
+	add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5);
397 392
 
398 393
 	$cache_key = "{$meta_key}_{$object_id}";
399
-	$check    = Give_Cache::get_db_query( $cache_key );
394
+	$check = Give_Cache::get_db_query($cache_key);
400 395
 
401
-	if ( is_null( $check ) ) {
402
-		switch ( $meta_key ) {
396
+	if (is_null($check)) {
397
+		switch ($meta_key) {
403 398
 
404 399
 			// Handle new meta keys.
405 400
 			case '_give_payment_donor_id':
@@ -442,9 +437,9 @@  discard block
 block discarded – undo
442 437
 			case '_give_donor_billing_country':
443 438
 			case '_give_payment_date':
444 439
 			case '_give_payment_currency':
445
-				$donation_meta = Give_Cache::get_db_query( "_give_payment_meta_{$object_id}" );
440
+				$donation_meta = Give_Cache::get_db_query("_give_payment_meta_{$object_id}");
446 441
 
447
-				if ( is_null( $donation_meta ) ) {
442
+				if (is_null($donation_meta)) {
448 443
 					$donation_meta = $wpdb->get_var(
449 444
 						$wpdb->prepare(
450 445
 							"SELECT meta_value FROM {$wpdb->postmeta} WHERE post_id=%d AND meta_key=%s",
@@ -452,51 +447,51 @@  discard block
 block discarded – undo
452 447
 							'_give_payment_meta'
453 448
 						)
454 449
 					);
455
-					$donation_meta = maybe_unserialize( $donation_meta );
456
-					$donation_meta = ! is_array( $donation_meta ) ? array() : $donation_meta;
457
-					Give_Cache::set_db_query( "_give_payment_meta_{$object_id}", $donation_meta );
450
+					$donation_meta = maybe_unserialize($donation_meta);
451
+					$donation_meta = ! is_array($donation_meta) ? array() : $donation_meta;
452
+					Give_Cache::set_db_query("_give_payment_meta_{$object_id}", $donation_meta);
458 453
 				}
459 454
 
460 455
 				// Get results.
461
-				if ( empty( $donation_meta ) ) {
456
+				if (empty($donation_meta)) {
462 457
 					$check = '';
463
-				} elseif ( in_array( $meta_key, array( '_give_payment_date', '_give_payment_currency' ) ) ) {
464
-					$payment_meta_key = str_replace( '_give_payment_', '', $meta_key );
458
+				} elseif (in_array($meta_key, array('_give_payment_date', '_give_payment_currency'))) {
459
+					$payment_meta_key = str_replace('_give_payment_', '', $meta_key);
465 460
 
466
-					if ( isset( $donation_meta[ $payment_meta_key ] ) ) {
467
-						$check = $donation_meta[ $payment_meta_key ];
461
+					if (isset($donation_meta[$payment_meta_key])) {
462
+						$check = $donation_meta[$payment_meta_key];
468 463
 					}
469 464
 				} else {
470
-					$payment_meta_key = str_replace( '_give_donor_billing_', '', $meta_key );
465
+					$payment_meta_key = str_replace('_give_donor_billing_', '', $meta_key);
471 466
 
472
-					switch ( $payment_meta_key ) {
467
+					switch ($payment_meta_key) {
473 468
 						case 'address1':
474
-							if ( isset( $donation_meta['user_info']['address']['line1'] ) ) {
469
+							if (isset($donation_meta['user_info']['address']['line1'])) {
475 470
 								$check = $donation_meta['user_info']['address']['line1'];
476 471
 							}
477 472
 							break;
478 473
 
479 474
 						case 'address2':
480
-							if ( isset( $donation_meta['user_info']['address']['line2'] ) ) {
475
+							if (isset($donation_meta['user_info']['address']['line2'])) {
481 476
 								$check = $donation_meta['user_info']['address']['line2'];
482 477
 							}
483 478
 							break;
484 479
 
485 480
 						case 'first_name':
486
-							if ( isset( $donation_meta['user_info']['first_name'] ) ) {
481
+							if (isset($donation_meta['user_info']['first_name'])) {
487 482
 								$check = $donation_meta['user_info']['first_name'];
488 483
 							}
489 484
 							break;
490 485
 
491 486
 						case 'last_name':
492
-							if ( isset( $donation_meta['user_info']['last_name'] ) ) {
487
+							if (isset($donation_meta['user_info']['last_name'])) {
493 488
 								$check = $donation_meta['user_info']['last_name'];
494 489
 							}
495 490
 							break;
496 491
 
497 492
 						default:
498
-							if ( isset( $donation_meta['user_info']['address'][ $payment_meta_key ] ) ) {
499
-								$check = $donation_meta['user_info']['address'][ $payment_meta_key ];
493
+							if (isset($donation_meta['user_info']['address'][$payment_meta_key])) {
494
+								$check = $donation_meta['user_info']['address'][$payment_meta_key];
500 495
 							}
501 496
 					}
502 497
 				}
@@ -505,19 +500,19 @@  discard block
 block discarded – undo
505 500
 		}// End switch().
506 501
 
507 502
 		// Set cache.
508
-		Give_Cache::set_db_query( $cache_key, $check );
503
+		Give_Cache::set_db_query($cache_key, $check);
509 504
 	}
510 505
 
511 506
 	// Put result in an array on zero index.
512
-	if ( ! $single ) {
513
-		$check = array( $check );
507
+	if ( ! $single) {
508
+		$check = array($check);
514 509
 	}
515 510
 
516 511
 
517 512
 	return $check;
518 513
 }
519 514
 
520
-add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 );
515
+add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5);
521 516
 
522 517
 
523 518
 /**
@@ -529,9 +524,9 @@  discard block
 block discarded – undo
529 524
  *
530 525
  * @return void
531 526
  */
532
-function _give_20_bc_support_deprecated_meta_key_query( $query ) {
527
+function _give_20_bc_support_deprecated_meta_key_query($query) {
533 528
 	// Bailout.
534
-	if ( give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) {
529
+	if (give_has_upgrade_completed('v20_upgrades_payment_metadata')) {
535 530
 		return;
536 531
 	}
537 532
 
@@ -541,21 +536,21 @@  discard block
 block discarded – undo
541 536
 		// '_give_payment_user_ip'     => '_give_payment_donor_ip',
542 537
 	);
543 538
 
544
-	$deprecated_meta_keys = array_flip( $new_meta_keys );
539
+	$deprecated_meta_keys = array_flip($new_meta_keys);
545 540
 
546 541
 	// Set meta keys.
547 542
 	$meta_keys = array();
548 543
 
549 544
 
550 545
 	// Bailout.
551
-	if ( ! empty( $query->query_vars['meta_key'] ) ) {
552
-		if ( in_array( $query->query_vars['meta_key'], $new_meta_keys ) ) {
546
+	if ( ! empty($query->query_vars['meta_key'])) {
547
+		if (in_array($query->query_vars['meta_key'], $new_meta_keys)) {
553 548
 			$meta_keys = $deprecated_meta_keys;
554
-		} elseif ( in_array( $query->query_vars['meta_key'], $deprecated_meta_keys ) ) {
549
+		} elseif (in_array($query->query_vars['meta_key'], $deprecated_meta_keys)) {
555 550
 			$meta_keys = $new_meta_keys;
556 551
 		}
557 552
 
558
-		if ( ! empty( $meta_keys ) ) {
553
+		if ( ! empty($meta_keys)) {
559 554
 			// Set meta_query
560 555
 			$query->set(
561 556
 				'meta_query',
@@ -566,35 +561,35 @@  discard block
 block discarded – undo
566 561
 						'value' => $query->query_vars['meta_value'],
567 562
 					),
568 563
 					array(
569
-						'key'   => $meta_keys[ $query->query_vars['meta_key'] ],
564
+						'key'   => $meta_keys[$query->query_vars['meta_key']],
570 565
 						'value' => $query->query_vars['meta_value'],
571 566
 					),
572 567
 				)
573 568
 			);
574 569
 
575 570
 			// Unset single meta query.
576
-			unset( $query->query_vars['meta_key'] );
577
-			unset( $query->query_vars['meta_value'] );
571
+			unset($query->query_vars['meta_key']);
572
+			unset($query->query_vars['meta_value']);
578 573
 		}
579 574
 	} elseif (
580
-		! empty( $query->query_vars['meta_query'] ) &&
581
-		( 1 === count( $query->query_vars['meta_query'] ) )
575
+		! empty($query->query_vars['meta_query']) &&
576
+		(1 === count($query->query_vars['meta_query']))
582 577
 	) {
583
-		$meta_query = current( $query->query_vars['meta_query'] );
578
+		$meta_query = current($query->query_vars['meta_query']);
584 579
 
585
-		if ( empty( $meta_query[0]['key'] ) ) {
580
+		if (empty($meta_query[0]['key'])) {
586 581
 			return;
587 582
 		}
588 583
 
589
-		if ( in_array( $meta_query[0]['key'], $new_meta_keys ) ) {
584
+		if (in_array($meta_query[0]['key'], $new_meta_keys)) {
590 585
 			$meta_keys = $deprecated_meta_keys;
591
-		} elseif ( in_array( $meta_query[0]['key'], $deprecated_meta_keys ) ) {
586
+		} elseif (in_array($meta_query[0]['key'], $deprecated_meta_keys)) {
592 587
 			$meta_keys = $new_meta_keys;
593 588
 		} else {
594 589
 			return;
595 590
 		}
596 591
 
597
-		if ( ! empty( $meta_keys ) ) {
592
+		if ( ! empty($meta_keys)) {
598 593
 			// Set meta_query
599 594
 			$query->set(
600 595
 				'meta_query',
@@ -605,7 +600,7 @@  discard block
 block discarded – undo
605 600
 						'value' => $query->query_vars['meta_query'][0]['value'],
606 601
 					),
607 602
 					array(
608
-						'key'   => $meta_keys[ $query->query_vars['meta_query'][0]['key'] ],
603
+						'key'   => $meta_keys[$query->query_vars['meta_query'][0]['key']],
609 604
 						'value' => $query->query_vars['meta_query'][0]['value'],
610 605
 					),
611 606
 				)
@@ -614,7 +609,7 @@  discard block
 block discarded – undo
614 609
 	}
615 610
 }
616 611
 
617
-add_action( 'pre_get_posts', '_give_20_bc_support_deprecated_meta_key_query' );
612
+add_action('pre_get_posts', '_give_20_bc_support_deprecated_meta_key_query');
618 613
 
619 614
 
620 615
 /**
@@ -627,49 +622,49 @@  discard block
 block discarded – undo
627 622
  * @param Give_Payment $payment
628 623
  * @param string       $key
629 624
  */
630
-function _give_20_bc_payment_save( $payment, $key ) {
625
+function _give_20_bc_payment_save($payment, $key) {
631 626
 	// Bailout.
632
-	if ( ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) {
627
+	if ( ! give_has_upgrade_completed('v20_upgrades_payment_metadata')) {
633 628
 		return;
634 629
 	}
635 630
 
636
-	switch ( $key ) {
631
+	switch ($key) {
637 632
 		case 'user_info':
638
-			if ( empty( $payment->user_info ) ) {
633
+			if (empty($payment->user_info)) {
639 634
 				// Bailout.
640 635
 				break;
641
-			} elseif ( is_string( $payment->user_info ) ) {
636
+			} elseif (is_string($payment->user_info)) {
642 637
 				// Check if value serialize.
643
-				$payment->user_info = maybe_unserialize( $payment->user_info );
638
+				$payment->user_info = maybe_unserialize($payment->user_info);
644 639
 			}
645 640
 
646 641
 
647 642
 			// Save first name.
648
-			if ( isset( $payment->user_info['first_name'] ) ) {
649
-				$payment->update_meta( '_give_donor_billing_first_name', $payment->user_info['first_name'] );
643
+			if (isset($payment->user_info['first_name'])) {
644
+				$payment->update_meta('_give_donor_billing_first_name', $payment->user_info['first_name']);
650 645
 			}
651 646
 
652 647
 
653 648
 			// Save last name.
654
-			if ( isset( $payment->user_info['last_name'] ) ) {
655
-				$payment->update_meta( '_give_donor_billing_last_name', $payment->user_info['last_name'] );
649
+			if (isset($payment->user_info['last_name'])) {
650
+				$payment->update_meta('_give_donor_billing_last_name', $payment->user_info['last_name']);
656 651
 			}
657 652
 
658 653
 
659 654
 			// Save address.
660
-			if ( ! empty( $payment->user_info['address'] ) ) {
661
-				foreach ( $payment->user_info['address'] as $address_name => $address ) {
662
-					switch ( $address_name ) {
655
+			if ( ! empty($payment->user_info['address'])) {
656
+				foreach ($payment->user_info['address'] as $address_name => $address) {
657
+					switch ($address_name) {
663 658
 						case 'line1':
664
-							$payment->update_meta( '_give_donor_billing_address1', $address );
659
+							$payment->update_meta('_give_donor_billing_address1', $address);
665 660
 							break;
666 661
 
667 662
 						case 'line2':
668
-							$payment->update_meta( '_give_donor_billing_address2', $address );
663
+							$payment->update_meta('_give_donor_billing_address2', $address);
669 664
 							break;
670 665
 
671 666
 						default:
672
-							$payment->update_meta( "_give_donor_billing_{$address_name}", $address );
667
+							$payment->update_meta("_give_donor_billing_{$address_name}", $address);
673 668
 					}
674 669
 				}
675 670
 			}
@@ -678,7 +673,7 @@  discard block
 block discarded – undo
678 673
 	}
679 674
 }
680 675
 
681
-add_action( 'give_payment_save', '_give_20_bc_payment_save', 10, 2 );
676
+add_action('give_payment_save', '_give_20_bc_payment_save', 10, 2);
682 677
 
683 678
 
684 679
 /**
@@ -691,16 +686,16 @@  discard block
 block discarded – undo
691 686
  *
692 687
  * @return mixed
693 688
  */
694
-function __give_20_bc_flush_cache( $check, $object_id ) {
689
+function __give_20_bc_flush_cache($check, $object_id) {
695 690
 	if (
696
-		! give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ) &&
697
-		'give_payment' === get_post_type( $object_id )
691
+		! give_has_upgrade_completed('v20_move_metadata_into_new_table') &&
692
+		'give_payment' === get_post_type($object_id)
698 693
 	) {
699
-		Give_Cache::delete_group( $object_id, 'give-donations' );
694
+		Give_Cache::delete_group($object_id, 'give-donations');
700 695
 	}
701 696
 
702 697
 	return $check;
703 698
 }
704 699
 
705
-add_action( 'update_post_metadata', '__give_20_bc_flush_cache', 9999, 2 );
706
-add_action( 'add_post_metadata', '__give_20_bc_flush_cache', 9999, 2 );
700
+add_action('update_post_metadata', '__give_20_bc_flush_cache', 9999, 2);
701
+add_action('add_post_metadata', '__give_20_bc_flush_cache', 9999, 2);
Please login to merge, or discard this patch.
includes/payments/class-payments-query.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @since  1.0
108 108
 	 * @access public
109 109
 	 *
110
-	 * @param $query_var
110
+	 * @param string $query_var
111 111
 	 * @param $value
112 112
 	 */
113 113
 	public function __set( $query_var, $value ) {
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @since  1.0
125 125
 	 * @access public
126 126
 	 *
127
-	 * @param $query_var
127
+	 * @param string $query_var
128 128
 	 */
129 129
 	public function __unset( $query_var ) {
130 130
 		unset( $this->args[ $query_var ] );
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @param string   $order
469 469
 	 * @param WP_Query $query
470 470
 	 *
471
-	 * @return mixed
471
+	 * @return string
472 472
 	 */
473 473
 	public function custom_orderby( $order, $query ) {
474 474
 
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param  $args array The array of arguments that can be passed in and used for setting up this payment query.
68 68
 	 */
69
-	public function __construct( $args = array() ) {
69
+	public function __construct($args = array()) {
70 70
 		$defaults = array(
71 71
 			'output'          => 'payments',
72
-			'post_type'       => array( 'give_payment' ),
72
+			'post_type'       => array('give_payment'),
73 73
 			'start_date'      => false,
74 74
 			'end_date'        => false,
75 75
 			'number'          => 20,
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			'count'           => false,
97 97
 		);
98 98
 
99
-		$this->args = $this->_args = wp_parse_args( $args, $defaults );
99
+		$this->args = $this->_args = wp_parse_args($args, $defaults);
100 100
 
101 101
 		$this->init();
102 102
 	}
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 	 * @param $query_var
111 111
 	 * @param $value
112 112
 	 */
113
-	public function __set( $query_var, $value ) {
114
-		if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) {
115
-			$this->args[ $query_var ][] = $value;
113
+	public function __set($query_var, $value) {
114
+		if (in_array($query_var, array('meta_query', 'tax_query'))) {
115
+			$this->args[$query_var][] = $value;
116 116
 		} else {
117
-			$this->args[ $query_var ] = $value;
117
+			$this->args[$query_var] = $value;
118 118
 		}
119 119
 	}
120 120
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @param $query_var
128 128
 	 */
129
-	public function __unset( $query_var ) {
130
-		unset( $this->args[ $query_var ] );
129
+	public function __unset($query_var) {
130
+		unset($this->args[$query_var]);
131 131
 	}
132 132
 
133 133
 	/**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		$this->give_forms();
168 168
 		$this->gateway_filter();
169 169
 
170
-		add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 );
170
+		add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2);
171 171
 
172 172
 		/**
173 173
 		 * Fires after setup filters.
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		 *
177 177
 		 * @param Give_Payments_Query $this Payments query object.
178 178
 		 */
179
-		do_action( 'give_pre_get_payments', $this );
179
+		do_action('give_pre_get_payments', $this);
180 180
 	}
181 181
 
182 182
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @access private
187 187
 	 */
188 188
 	private function unset_filters() {
189
-		remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) );
189
+		remove_filter('posts_orderby', array($this, 'custom_orderby'));
190 190
 
191 191
 		/**
192 192
 		 * Fires after retrieving payments.
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		 *
196 196
 		 * @param Give_Payments_Query $this Payments query object.
197 197
 		 */
198
-		do_action( 'give_post_get_payments', $this );
198
+		do_action('give_post_get_payments', $this);
199 199
 	}
200 200
 
201 201
 
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
 	public function get_payments() {
215 215
 		global $post;
216 216
 
217
-		$cache_key      = Give_Cache::get_key( 'give_payment_query', $this->args, false );
218
-		$this->payments = Give_Cache::get_db_query( $cache_key );
217
+		$cache_key      = Give_Cache::get_key('give_payment_query', $this->args, false);
218
+		$this->payments = Give_Cache::get_db_query($cache_key);
219 219
 
220 220
 		// Return cached result.
221
-		if ( ! is_null( $this->payments ) ) {
221
+		if ( ! is_null($this->payments)) {
222 222
 			return $this->payments;
223 223
 		}
224 224
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		// Modify the query/query arguments before we retrieve payments.
227 227
 		$this->set_filters();
228 228
 
229
-		$query          = new WP_Query( $this->args );
229
+		$query          = new WP_Query($this->args);
230 230
 		$this->payments = array();
231 231
 
232 232
 		$custom_output = array(
@@ -234,32 +234,32 @@  discard block
 block discarded – undo
234 234
 			'give_payments',
235 235
 		);
236 236
 
237
-		if ( ! in_array( $this->args['output'], $custom_output ) ) {
237
+		if ( ! in_array($this->args['output'], $custom_output)) {
238 238
 			return $query->posts;
239 239
 		}
240 240
 
241
-		if ( $query->have_posts() ) {
241
+		if ($query->have_posts()) {
242 242
 			$previous_post = $post;
243 243
 
244
-			while ( $query->have_posts() ) {
244
+			while ($query->have_posts()) {
245 245
 				$query->the_post();
246 246
 
247 247
 				$payment_id = get_post()->ID;
248
-				$payment    = new Give_Payment( $payment_id );
248
+				$payment    = new Give_Payment($payment_id);
249 249
 
250
-				$this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this );
250
+				$this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this);
251 251
 			}
252 252
 
253 253
 			wp_reset_postdata();
254 254
 
255 255
 			// Prevent nest loop from producing unexpected results.
256
-			if( $previous_post instanceof WP_Post ) {
256
+			if ($previous_post instanceof WP_Post) {
257 257
 				$post = $previous_post;
258
-				setup_postdata( $post );
258
+				setup_postdata($post);
259 259
 			}
260 260
 		}
261 261
 
262
-		Give_Cache::set_db_query( $cache_key, $this->payments );
262
+		Give_Cache::set_db_query($cache_key, $this->payments);
263 263
 
264 264
 		// Remove query filters after we retrieve payments.
265 265
 		$this->unset_filters();
@@ -278,31 +278,31 @@  discard block
 block discarded – undo
278 278
 	public function get_payment_by_group() {
279 279
 		global $wpdb;
280 280
 
281
-		$allowed_groups = array( 'post_status' );
281
+		$allowed_groups = array('post_status');
282 282
 		$result         = array();
283 283
 
284 284
 
285
-		if ( in_array( $this->args['group_by'], $allowed_groups ) ) {
285
+		if (in_array($this->args['group_by'], $allowed_groups)) {
286 286
 			// Set only count in result.
287
-			if ( $this->args['count'] ) {
287
+			if ($this->args['count']) {
288 288
 
289 289
 				$this->set_filters();
290 290
 
291
-				$new_results = $wpdb->get_results( $this->get_sql(), ARRAY_N );
291
+				$new_results = $wpdb->get_results($this->get_sql(), ARRAY_N);
292 292
 
293 293
 				$this->unset_filters();
294 294
 
295
-				foreach ( $new_results as $results ) {
296
-					$result[ $results[0] ] = $results[1];
295
+				foreach ($new_results as $results) {
296
+					$result[$results[0]] = $results[1];
297 297
 				}
298 298
 
299
-				switch ( $this->args['group_by'] ) {
299
+				switch ($this->args['group_by']) {
300 300
 					case 'post_status':
301 301
 
302 302
 						/* @var Give_Payment $donation */
303
-						foreach ( give_get_payment_status_keys() as $status ) {
304
-							if ( ! isset( $result[ $status ] ) ) {
305
-								$result[ $status ] = 0;
303
+						foreach (give_get_payment_status_keys() as $status) {
304
+							if ( ! isset($result[$status])) {
305
+								$result[$status] = 0;
306 306
 							}
307 307
 						}
308 308
 
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 				$donations = $this->get_payments();
313 313
 
314 314
 				/* @var $donation Give_Payment */
315
-				foreach ( $donations as $donation ) {
316
-					$result[ $donation->{$this->args['group_by']} ][] = $donation;
315
+				foreach ($donations as $donation) {
316
+					$result[$donation->{$this->args['group_by']}][] = $donation;
317 317
 				}
318 318
 			}
319 319
 		}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		 *
325 325
 		 * @since 1.8.17
326 326
 		 */
327
-		return apply_filters( 'give_get_payment_by_group', $result, $this );
327
+		return apply_filters('give_get_payment_by_group', $result, $this);
328 328
 	}
329 329
 
330 330
 	/**
@@ -336,29 +336,29 @@  discard block
 block discarded – undo
336 336
 	 * @return void
337 337
 	 */
338 338
 	public function date_filter_pre() {
339
-		if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) {
339
+		if ( ! ($this->args['start_date'] || $this->args['end_date'])) {
340 340
 			return;
341 341
 		}
342 342
 
343
-		$this->setup_dates( $this->args['start_date'], $this->args['end_date'] );
344
-		$is_start_date = property_exists( __CLASS__, 'start_date' );
345
-		$is_end_date   = property_exists( __CLASS__, 'end_date' );
343
+		$this->setup_dates($this->args['start_date'], $this->args['end_date']);
344
+		$is_start_date = property_exists(__CLASS__, 'start_date');
345
+		$is_end_date   = property_exists(__CLASS__, 'end_date');
346 346
 
347
-		if ( $is_start_date || $is_end_date ) {
347
+		if ($is_start_date || $is_end_date) {
348 348
 			$date_query = array();
349 349
 
350
-			if ( $is_start_date && ! is_wp_error( $this->start_date ) ) {
351
-				$date_query['after'] = date( 'Y-m-d H:i:s', $this->start_date );
350
+			if ($is_start_date && ! is_wp_error($this->start_date)) {
351
+				$date_query['after'] = date('Y-m-d H:i:s', $this->start_date);
352 352
 			}
353 353
 
354
-			if ( $is_end_date && ! is_wp_error( $this->end_date ) ) {
355
-				$date_query['before'] = date( 'Y-m-d H:i:s', $this->end_date );
354
+			if ($is_end_date && ! is_wp_error($this->end_date)) {
355
+				$date_query['before'] = date('Y-m-d H:i:s', $this->end_date);
356 356
 			}
357 357
 
358 358
 			// Include Start Date and End Date while querying.
359 359
 			$date_query['inclusive'] = true;
360 360
 
361
-			$this->__set( 'date_query', $date_query );
361
+			$this->__set('date_query', $date_query);
362 362
 
363 363
 		}
364 364
 	}
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
 	 * @return void
373 373
 	 */
374 374
 	public function status() {
375
-		if ( ! isset( $this->args['status'] ) ) {
375
+		if ( ! isset($this->args['status'])) {
376 376
 			return;
377 377
 		}
378 378
 
379
-		$this->__set( 'post_status', $this->args['status'] );
380
-		$this->__unset( 'status' );
379
+		$this->__set('post_status', $this->args['status']);
380
+		$this->__unset('status');
381 381
 	}
382 382
 
383 383
 	/**
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 	 * @return void
390 390
 	 */
391 391
 	public function page() {
392
-		if ( ! isset( $this->args['page'] ) ) {
392
+		if ( ! isset($this->args['page'])) {
393 393
 			return;
394 394
 		}
395 395
 
396
-		$this->__set( 'paged', $this->args['page'] );
397
-		$this->__unset( 'page' );
396
+		$this->__set('paged', $this->args['page']);
397
+		$this->__unset('page');
398 398
 	}
399 399
 
400 400
 	/**
@@ -407,17 +407,17 @@  discard block
 block discarded – undo
407 407
 	 */
408 408
 	public function per_page() {
409 409
 
410
-		if ( ! isset( $this->args['number'] ) ) {
410
+		if ( ! isset($this->args['number'])) {
411 411
 			return;
412 412
 		}
413 413
 
414
-		if ( $this->args['number'] == - 1 ) {
415
-			$this->__set( 'nopaging', true );
414
+		if ($this->args['number'] == - 1) {
415
+			$this->__set('nopaging', true);
416 416
 		} else {
417
-			$this->__set( 'posts_per_page', $this->args['number'] );
417
+			$this->__set('posts_per_page', $this->args['number']);
418 418
 		}
419 419
 
420
-		$this->__unset( 'number' );
420
+		$this->__unset('number');
421 421
 	}
422 422
 
423 423
 	/**
@@ -429,12 +429,12 @@  discard block
 block discarded – undo
429 429
 	 * @return void
430 430
 	 */
431 431
 	public function month() {
432
-		if ( ! isset( $this->args['month'] ) ) {
432
+		if ( ! isset($this->args['month'])) {
433 433
 			return;
434 434
 		}
435 435
 
436
-		$this->__set( 'monthnum', $this->args['month'] );
437
-		$this->__unset( 'month' );
436
+		$this->__set('monthnum', $this->args['month']);
437
+		$this->__unset('month');
438 438
 	}
439 439
 
440 440
 	/**
@@ -446,23 +446,23 @@  discard block
 block discarded – undo
446 446
 	 * @return void
447 447
 	 */
448 448
 	public function orderby() {
449
-		switch ( $this->args['orderby'] ) {
449
+		switch ($this->args['orderby']) {
450 450
 			case 'amount':
451
-				$this->__set( 'orderby', 'meta_value_num' );
452
-				$this->__set( 'meta_key', '_give_payment_total' );
451
+				$this->__set('orderby', 'meta_value_num');
452
+				$this->__set('meta_key', '_give_payment_total');
453 453
 				break;
454 454
 
455 455
 			case 'status':
456
-				$this->__set( 'orderby', 'post_status' );
456
+				$this->__set('orderby', 'post_status');
457 457
 				break;
458 458
 
459 459
 			case 'donation_form':
460
-				$this->__set( 'orderby', 'meta_value' );
461
-				$this->__set( 'meta_key', '_give_payment_form_title' );
460
+				$this->__set('orderby', 'meta_value');
461
+				$this->__set('meta_key', '_give_payment_form_title');
462 462
 				break;
463 463
 
464 464
 			default:
465
-				$this->__set( 'orderby', $this->args['orderby'] );
465
+				$this->__set('orderby', $this->args['orderby']);
466 466
 				break;
467 467
 		}
468 468
 	}
@@ -479,19 +479,19 @@  discard block
 block discarded – undo
479 479
 	 *
480 480
 	 * @return mixed
481 481
 	 */
482
-	public function custom_orderby( $order, $query ) {
482
+	public function custom_orderby($order, $query) {
483 483
 
484
-		if ( ! empty( $query->query['post_type'] ) ) {
485
-			$post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] );
484
+		if ( ! empty($query->query['post_type'])) {
485
+			$post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']);
486 486
 
487
-			if ( ! in_array( 'give_payment', $post_types ) || ! isset( $query->query['orderby'] ) || is_array( $query->query['orderby'] ) ) {
487
+			if ( ! in_array('give_payment', $post_types) || ! isset($query->query['orderby']) || is_array($query->query['orderby'])) {
488 488
 				return $order;
489 489
 			}
490 490
 
491 491
 			global $wpdb;
492
-			switch ( $query->query['orderby'] ) {
492
+			switch ($query->query['orderby']) {
493 493
 				case 'post_status':
494
-					$order = $wpdb->posts . '.post_status ' . strtoupper( $query->query['order'] );
494
+					$order = $wpdb->posts.'.post_status '.strtoupper($query->query['order']);
495 495
 					break;
496 496
 			}
497 497
 		}
@@ -508,29 +508,29 @@  discard block
 block discarded – undo
508 508
 	 * @return void
509 509
 	 */
510 510
 	public function user() {
511
-		if ( is_null( $this->args['user'] ) ) {
511
+		if (is_null($this->args['user'])) {
512 512
 			return;
513 513
 		}
514 514
 
515 515
 
516 516
 		$args = array();
517 517
 
518
-		if ( is_numeric( $this->args['user'] ) ) {
518
+		if (is_numeric($this->args['user'])) {
519 519
 			// Backward compatibility: user donor param to get payment attached to donor instead of user
520
-			$donor_id = Give()->donors->get_column_by( 'id', is_numeric( $this->args['user'] ) ? 'user_id' : 'email', $this->args['user'] );
520
+			$donor_id = Give()->donors->get_column_by('id', is_numeric($this->args['user']) ? 'user_id' : 'email', $this->args['user']);
521 521
 
522 522
 			$args = array(
523 523
 				'key'   => '_give_payment_donor_id',
524
-				'value' => absint( $donor_id ),
524
+				'value' => absint($donor_id),
525 525
 			);
526
-		} elseif ( is_email( $this->args['user'] ) ) {
526
+		} elseif (is_email($this->args['user'])) {
527 527
 			$args = array(
528 528
 				'key'   => '_give_payment_donor_email',
529 529
 				'value' => $this->args['user'],
530 530
 			);
531 531
 		}
532 532
 
533
-		$this->__set( 'meta_query',$args );
533
+		$this->__set('meta_query', $args);
534 534
 	}
535 535
 
536 536
 	/**
@@ -541,16 +541,16 @@  discard block
 block discarded – undo
541 541
 	 * @return  void
542 542
 	 */
543 543
 	public function donor() {
544
-		if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) {
544
+		if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) {
545 545
 			return;
546 546
 		}
547 547
 
548 548
 		$donor_meta_type = Give()->donor_meta->meta_type;
549 549
 
550
-		$this->__set( 'meta_query', array(
550
+		$this->__set('meta_query', array(
551 551
 			'key'   => "_give_payment_{$donor_meta_type}_id",
552 552
 			'value' => (int) $this->args['donor'],
553
-		) );
553
+		));
554 554
 	}
555 555
 
556 556
 	/**
@@ -563,33 +563,33 @@  discard block
 block discarded – undo
563 563
 	 */
564 564
 	public function search() {
565 565
 
566
-		if ( ! isset( $this->args['s'] ) ) {
566
+		if ( ! isset($this->args['s'])) {
567 567
 			return;
568 568
 		}
569 569
 
570
-		$search = trim( $this->args['s'] );
570
+		$search = trim($this->args['s']);
571 571
 
572
-		if ( empty( $search ) ) {
572
+		if (empty($search)) {
573 573
 			return;
574 574
 		}
575 575
 
576
-		$is_email = is_email( $search ) || strpos( $search, '@' ) !== false;
577
-		$is_user  = strpos( $search, strtolower( 'user:' ) ) !== false;
576
+		$is_email = is_email($search) || strpos($search, '@') !== false;
577
+		$is_user  = strpos($search, strtolower('user:')) !== false;
578 578
 
579
-		if ( ! empty( $this->args['search_in_notes'] ) ) {
579
+		if ( ! empty($this->args['search_in_notes'])) {
580 580
 
581
-			$notes = give_get_payment_notes( 0, $search );
581
+			$notes = give_get_payment_notes(0, $search);
582 582
 
583
-			if ( ! empty( $notes ) ) {
583
+			if ( ! empty($notes)) {
584 584
 
585
-				$payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' );
585
+				$payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID');
586 586
 
587
-				$this->__set( 'post__in', $payment_ids );
587
+				$this->__set('post__in', $payment_ids);
588 588
 			}
589 589
 
590
-			$this->__unset( 's' );
590
+			$this->__unset('s');
591 591
 
592
-		} elseif ( $is_email || strlen( $search ) == 32 ) {
592
+		} elseif ($is_email || strlen($search) == 32) {
593 593
 
594 594
 			$key         = $is_email ? '_give_payment_donor_email' : '_give_payment_purchase_key';
595 595
 			$search_meta = array(
@@ -598,40 +598,40 @@  discard block
 block discarded – undo
598 598
 				'compare' => 'LIKE',
599 599
 			);
600 600
 
601
-			$this->__set( 'meta_query', $search_meta );
602
-			$this->__unset( 's' );
601
+			$this->__set('meta_query', $search_meta);
602
+			$this->__unset('s');
603 603
 
604
-		} elseif ( $is_user ) {
604
+		} elseif ($is_user) {
605 605
 
606 606
 			$search_meta = array(
607 607
 				'key'   => '_give_payment_donor_id',
608
-				'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ),
608
+				'value' => trim(str_replace('user:', '', strtolower($search))),
609 609
 			);
610 610
 
611
-			$this->__set( 'meta_query', $search_meta );
611
+			$this->__set('meta_query', $search_meta);
612 612
 
613
-			$this->__unset( 's' );
613
+			$this->__unset('s');
614 614
 
615
-		} elseif ( is_numeric( $search ) ) {
615
+		} elseif (is_numeric($search)) {
616 616
 
617
-			$post = get_post( $search );
617
+			$post = get_post($search);
618 618
 
619
-			if ( is_object( $post ) && $post->post_type == 'give_payment' ) {
619
+			if (is_object($post) && $post->post_type == 'give_payment') {
620 620
 
621 621
 				$arr   = array();
622 622
 				$arr[] = $search;
623
-				$this->__set( 'post__in', $arr );
624
-				$this->__unset( 's' );
623
+				$this->__set('post__in', $arr);
624
+				$this->__unset('s');
625 625
 			}
626
-		} elseif ( '#' == substr( $search, 0, 1 ) ) {
626
+		} elseif ('#' == substr($search, 0, 1)) {
627 627
 
628
-			$search = str_replace( '#:', '', $search );
629
-			$search = str_replace( '#', '', $search );
630
-			$this->__set( 'give_forms', $search );
631
-			$this->__unset( 's' );
628
+			$search = str_replace('#:', '', $search);
629
+			$search = str_replace('#', '', $search);
630
+			$this->__set('give_forms', $search);
631
+			$this->__unset('s');
632 632
 
633 633
 		} else {
634
-			$this->__set( 's', $search );
634
+			$this->__set('s', $search);
635 635
 
636 636
 		}
637 637
 
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 	 * @return void
647 647
 	 */
648 648
 	public function mode() {
649
-		if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) {
650
-			$this->__unset( 'mode' );
649
+		if (empty($this->args['mode']) || $this->args['mode'] == 'all') {
650
+			$this->__unset('mode');
651 651
 
652 652
 			return;
653 653
 		}
@@ -669,10 +669,10 @@  discard block
 block discarded – undo
669 669
 	 * @return void
670 670
 	 */
671 671
 	public function children() {
672
-		if ( empty( $this->args['children'] ) ) {
673
-			$this->__set( 'post_parent', 0 );
672
+		if (empty($this->args['children'])) {
673
+			$this->__set('post_parent', 0);
674 674
 		}
675
-		$this->__unset( 'children' );
675
+		$this->__unset('children');
676 676
 	}
677 677
 
678 678
 	/**
@@ -685,13 +685,13 @@  discard block
 block discarded – undo
685 685
 	 */
686 686
 	public function give_forms() {
687 687
 
688
-		if ( empty( $this->args['give_forms'] ) ) {
688
+		if (empty($this->args['give_forms'])) {
689 689
 			return;
690 690
 		}
691 691
 
692 692
 		$compare = '=';
693 693
 
694
-		if ( is_array( $this->args['give_forms'] ) ) {
694
+		if (is_array($this->args['give_forms'])) {
695 695
 			$compare = 'IN';
696 696
 		}
697 697
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 			)
705 705
 		);
706 706
 
707
-		$this->__unset( 'give_forms' );
707
+		$this->__unset('give_forms');
708 708
 
709 709
 	}
710 710
 
@@ -718,13 +718,13 @@  discard block
 block discarded – undo
718 718
 	 */
719 719
 	public function gateway_filter() {
720 720
 
721
-		if ( empty( $this->args['gateway'] ) ) {
721
+		if (empty($this->args['gateway'])) {
722 722
 			return;
723 723
 		}
724 724
 
725 725
 		$compare = '=';
726 726
 
727
-		if ( is_array( $this->args['gateway'] ) ) {
727
+		if (is_array($this->args['gateway'])) {
728 728
 			$compare = 'IN';
729 729
 		}
730 730
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 			)
739 739
 		);
740 740
 
741
-		$this->__unset( 'gateway' );
741
+		$this->__unset('gateway');
742 742
 
743 743
 	}
744 744
 
@@ -758,9 +758,9 @@  discard block
 block discarded – undo
758 758
 		global $wpdb;
759 759
 
760 760
 		$where = "WHERE {$wpdb->posts}.post_type = 'give_payment'";
761
-		$where .= " AND {$wpdb->posts}.post_status IN ('" . implode( "','", $this->args['post_status'] ) . "')";
761
+		$where .= " AND {$wpdb->posts}.post_status IN ('".implode("','", $this->args['post_status'])."')";
762 762
 
763
-		if( is_numeric( $this->args['post_parent'] ) ) {
763
+		if (is_numeric($this->args['post_parent'])) {
764 764
 			$where .= " AND {$wpdb->posts}.post_parent={$this->args['post_parent']}";
765 765
 		}
766 766
 
@@ -769,42 +769,42 @@  discard block
 block discarded – undo
769 769
 		$group_by = '';
770 770
 
771 771
 		// Set group by.
772
-		if ( ! empty( $this->args['group_by'] ) ) {
772
+		if ( ! empty($this->args['group_by'])) {
773 773
 			$group_by = "GROUP BY {$wpdb->posts}.{$this->args['group_by']}";
774 774
 		}
775 775
 
776 776
 		// Set offset.
777 777
 		if (
778
-			empty( $this->args['nopaging'] ) &&
779
-			empty( $this->args['offset'] ) &&
780
-			( ! empty( $this->args['page'] ) && 0 < $this->args['page'] )
778
+			empty($this->args['nopaging']) &&
779
+			empty($this->args['offset']) &&
780
+			( ! empty($this->args['page']) && 0 < $this->args['page'])
781 781
 		) {
782
-			$this->args['offset'] = $this->args['posts_per_page'] * ( $this->args['page'] - 1 );
782
+			$this->args['offset'] = $this->args['posts_per_page'] * ($this->args['page'] - 1);
783 783
 		}
784 784
 
785 785
 		// Set fields.
786 786
 		$fields = "{$wpdb->posts}.*";
787
-		if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) {
788
-			if ( is_string( $this->args['fields'] ) ) {
787
+		if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) {
788
+			if (is_string($this->args['fields'])) {
789 789
 				$fields = "{$wpdb->posts}.{$this->args['fields']}";
790
-			} elseif ( is_array( $this->args['fields'] ) ) {
791
-				$fields = "{$wpdb->posts}." . implode( " , {$wpdb->posts}.", $this->args['fields'] );
790
+			} elseif (is_array($this->args['fields'])) {
791
+				$fields = "{$wpdb->posts}.".implode(" , {$wpdb->posts}.", $this->args['fields']);
792 792
 			}
793 793
 		}
794 794
 
795 795
 		// Set count.
796
-		if ( ! empty( $this->args['count'] ) ) {
796
+		if ( ! empty($this->args['count'])) {
797 797
 			$fields = "COUNT({$wpdb->posts}.ID)";
798 798
 
799
-			if ( ! empty( $this->args['group_by'] ) ) {
799
+			if ( ! empty($this->args['group_by'])) {
800 800
 				$fields = "{$wpdb->posts}.{$this->args['group_by']}, {$fields}";
801 801
 			}
802 802
 		}
803 803
 
804 804
 		// Date query.
805
-		if ( ! empty( $this->args['date_query'] ) ) {
806
-			$date_query_obj = new WP_Date_Query( $this->args['date_query'] );
807
-			$where          .= str_replace(
805
+		if ( ! empty($this->args['date_query'])) {
806
+			$date_query_obj = new WP_Date_Query($this->args['date_query']);
807
+			$where .= str_replace(
808 808
 				array(
809 809
 					"\n",
810 810
 					'(   (',
@@ -820,22 +820,22 @@  discard block
 block discarded – undo
820 820
 		}
821 821
 
822 822
 		// Meta query.
823
-		if ( ! empty( $this->args['meta_query'] ) ) {
824
-			$meta_query_obj = new WP_Meta_Query( $this->args['meta_query'] );
825
-			$where          = implode( ' ', $meta_query_obj->get_sql( 'post', $wpdb->posts, 'ID' ) ) . " {$where}";
826
-			$where          = Give()->payment_meta->__rename_meta_table_name( $where, 'posts_where' );
823
+		if ( ! empty($this->args['meta_query'])) {
824
+			$meta_query_obj = new WP_Meta_Query($this->args['meta_query']);
825
+			$where          = implode(' ', $meta_query_obj->get_sql('post', $wpdb->posts, 'ID'))." {$where}";
826
+			$where          = Give()->payment_meta->__rename_meta_table_name($where, 'posts_where');
827 827
 		}
828 828
 
829 829
 		// Set sql query.
830 830
 		$sql = $wpdb->prepare(
831 831
 			"SELECT {$fields} FROM {$wpdb->posts} LIMIT %d,%d;",
832
-			absint( $this->args['offset'] ),
833
-			( empty( $this->args['nopaging'] ) ? absint( $this->args['posts_per_page'] ) : 99999999999 )
832
+			absint($this->args['offset']),
833
+			(empty($this->args['nopaging']) ? absint($this->args['posts_per_page']) : 99999999999)
834 834
 		);
835 835
 
836 836
 		// $where, $orderby and order already prepared query they can generate notice if you re prepare them in above.
837 837
 		// WordPress consider LIKE condition as placeholder if start with s,f, or d.
838
-		$sql = str_replace( 'LIMIT', "{$where} {$group_by} {$orderby} {$this->args['order']} LIMIT", $sql );
838
+		$sql = str_replace('LIMIT', "{$where} {$group_by} {$orderby} {$this->args['order']} LIMIT", $sql);
839 839
 
840 840
 		return $sql;
841 841
 	}
Please login to merge, or discard this patch.
includes/admin/tools/logs/class-gateway-error-logs-list-table.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16 16
 // Load WP_List_Table if not loaded.
17
-if ( ! class_exists( 'WP_List_Table' ) ) {
18
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17
+if ( ! class_exists('WP_List_Table')) {
18
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
19 19
 }
20 20
 
21 21
 /**
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	public function __construct() {
46 46
 		// Set parent defaults.
47
-		parent::__construct( array(
48
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
49
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records.
50
-			'ajax'     => false,// Does this table support ajax?.
51
-		) );
47
+		parent::__construct(array(
48
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
49
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
50
+			'ajax'     => false, // Does this table support ajax?.
51
+		));
52 52
 	}
53 53
 
54 54
 	/**
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return string Column Name.
64 64
 	 */
65
-	public function column_default( $item, $column_name ) {
65
+	public function column_default($item, $column_name) {
66 66
 
67
-		switch ( $column_name ) {
67
+		switch ($column_name) {
68 68
 			case 'ID' :
69 69
 				return $item['ID_label'];
70 70
 			case 'payment_id' :
71
-				return empty( $item['payment_id'] ) ? esc_html__( 'n/a', 'give' ) : sprintf( "<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link( $item['payment_id'] ) );
71
+				return empty($item['payment_id']) ? esc_html__('n/a', 'give') : sprintf("<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link($item['payment_id']));
72 72
 			case 'gateway' :
73
-				return empty( $item['gateway'] ) ? esc_html__( 'n/a', 'give' ) : $item['gateway'];
73
+				return empty($item['gateway']) ? esc_html__('n/a', 'give') : $item['gateway'];
74 74
 			case 'error' :
75
-				return esc_html( $item['log_title'] );
75
+				return esc_html($item['log_title']);
76 76
 			default:
77
-				return $item[ $column_name ];
77
+				return $item[$column_name];
78 78
 		}
79 79
 	}
80 80
 
@@ -88,35 +88,35 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return void
90 90
 	 */
91
-	public function column_message( $item ) {
91
+	public function column_message($item) {
92 92
 		?>
93 93
 		<?php
94
-		echo Give()->tooltips->render_link( array(
95
-			'label'       => __( 'View Log Message', 'give' ),
94
+		echo Give()->tooltips->render_link(array(
95
+			'label'       => __('View Log Message', 'give'),
96 96
 			'tag_content' => '<span class="dashicons dashicons-visibility"></span>',
97 97
 			'link'        => "#TB_inline?width=640&amp;inlineId=log-message-{$item['ID']}",
98 98
 			'attributes'  => array(
99 99
 				'class' => 'thickbox give-error-log-details-link button button-small',
100 100
 			),
101
-		) );
101
+		));
102 102
 		?>
103 103
 		<div id="log-message-<?php echo $item['ID']; ?>" style="display:none;">
104 104
 			<?php
105 105
 
106
-			$serialized = strpos( $item['log_content'], '{"' );
106
+			$serialized = strpos($item['log_content'], '{"');
107 107
 
108 108
 			// Check to see if the log message contains serialized information
109
-			if ( $serialized !== false ) {
110
-				$length = strlen( $item['log_content'] ) - $serialized;
111
-				$intro  = substr( $item['log_content'], 0, - $length );
112
-				$data   = substr( $item['log_content'], $serialized, strlen( $item['log_content'] ) - 1 );
109
+			if ($serialized !== false) {
110
+				$length = strlen($item['log_content']) - $serialized;
111
+				$intro  = substr($item['log_content'], 0, - $length);
112
+				$data   = substr($item['log_content'], $serialized, strlen($item['log_content']) - 1);
113 113
 
114
-				echo wpautop( $intro );
115
-				echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' );
116
-				echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>';
114
+				echo wpautop($intro);
115
+				echo wpautop('<strong>'.esc_html__('Log data:', 'give').'</strong>');
116
+				echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>';
117 117
 			} else {
118 118
 				// No serialized data found
119
-				echo wpautop( $item['log_content'] );
119
+				echo wpautop($item['log_content']);
120 120
 			}
121 121
 			?>
122 122
 		</div>
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public function get_columns() {
134 134
 		$columns = array(
135
-			'ID'         => esc_html__( 'Log ID', 'give' ),
136
-			'error'      => esc_html__( 'Error', 'give' ),
137
-			'gateway'    => esc_html__( 'Gateway', 'give' ),
138
-			'payment_id' => esc_html__( 'Donation ID', 'give' ),
139
-			'date'       => esc_html__( 'Date', 'give' ),
140
-			'message'    => esc_html__( 'Details', 'give' ),
135
+			'ID'         => esc_html__('Log ID', 'give'),
136
+			'error'      => esc_html__('Error', 'give'),
137
+			'gateway'    => esc_html__('Gateway', 'give'),
138
+			'payment_id' => esc_html__('Donation ID', 'give'),
139
+			'date'       => esc_html__('Date', 'give'),
140
+			'message'    => esc_html__('Details', 'give'),
141 141
 		);
142 142
 
143 143
 		return $columns;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @return int Current page number
152 152
 	 */
153 153
 	public function get_paged() {
154
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
154
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
155 155
 	}
156 156
 
157 157
 	/**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @since  1.0
162 162
 	 * @return void
163 163
 	 */
164
-	public function bulk_actions( $which = '' ) {
164
+	public function bulk_actions($which = '') {
165 165
 		give_log_views();
166 166
 	}
167 167
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	public function get_logs() {
177 177
 		// Prevent the queries from getting cached.
178 178
 		// Without this there are occasional memory issues for some installs.
179
-		wp_suspend_cache_addition( true );
179
+		wp_suspend_cache_addition(true);
180 180
 
181 181
 		$logs_data = array();
182 182
 		$paged     = $this->get_paged();
@@ -186,17 +186,17 @@  discard block
 block discarded – undo
186 186
 			'posts_per_page' => $this->per_page,
187 187
 		);
188 188
 
189
-		$logs = Give()->logs->get_connected_logs( $log_query );
189
+		$logs = Give()->logs->get_connected_logs($log_query);
190 190
 
191
-		if ( $logs ) {
192
-			foreach ( $logs as $log ) {
191
+		if ($logs) {
192
+			foreach ($logs as $log) {
193 193
 
194 194
 				$logs_data[] = array(
195 195
 					'ID'          => $log->ID,
196
-					'ID_label'    => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>',
196
+					'ID_label'    => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>',
197 197
 					'payment_id'  => $log->log_parent,
198 198
 					'error'       => 'error',
199
-					'gateway'     => give_get_payment_gateway( $log->log_parent ),
199
+					'gateway'     => give_get_payment_gateway($log->log_parent),
200 200
 					'date'        => $log->log_date,
201 201
 					'log_content' => $log->log_content,
202 202
 					'log_title'   => $log->log_title,
@@ -220,19 +220,19 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @param string $which
222 222
 	 */
223
-	protected function display_tablenav( $which ) {
224
-		if ( 'top' === $which ) {
225
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
223
+	protected function display_tablenav($which) {
224
+		if ('top' === $which) {
225
+			wp_nonce_field('bulk-'.$this->_args['plural']);
226 226
 		}
227 227
 		?>
228
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
228
+		<div class="tablenav <?php echo esc_attr($which); ?>">
229 229
 
230 230
 			<div class="alignleft actions bulkactions">
231
-				<?php $this->bulk_actions( $which ); ?>
231
+				<?php $this->bulk_actions($which); ?>
232 232
 			</div>
233 233
 			<?php
234
-			$this->extra_tablenav( $which );
235
-			$this->pagination( $which );
234
+			$this->extra_tablenav($which);
235
+			$this->pagination($which);
236 236
 			?>
237 237
 
238 238
 			<br class="clear"/>
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
 		$columns               = $this->get_columns();
259 259
 		$hidden                = array(); // No hidden columns
260 260
 		$sortable              = $this->get_sortable_columns();
261
-		$this->_column_headers = array( $columns, $hidden, $sortable );
261
+		$this->_column_headers = array($columns, $hidden, $sortable);
262 262
 		$this->items           = $this->get_logs();
263
-		$total_items           = Give()->logs->get_log_count( 0, 'gateway_error' );
263
+		$total_items           = Give()->logs->get_log_count(0, 'gateway_error');
264 264
 
265
-		$this->set_pagination_args( array(
265
+		$this->set_pagination_args(array(
266 266
 				'total_items' => $total_items,
267 267
 				'per_page'    => $this->per_page,
268
-				'total_pages' => ceil( $total_items / $this->per_page ),
268
+				'total_pages' => ceil($total_items / $this->per_page),
269 269
 			)
270 270
 		);
271 271
 	}
Please login to merge, or discard this patch.