Test Failed
Pull Request — master (#2482)
by Devin
05:37
created
includes/admin/tools/views/html-admin-page-data.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
  * Admin View: Exports
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if ( ! defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 
10
-if ( ! current_user_can( 'manage_give_settings' ) ) {
10
+if ( ! current_user_can('manage_give_settings')) {
11 11
 	return;
12 12
 }
13 13
 
@@ -16,29 +16,29 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * @since 1.5
18 18
  */
19
-do_action( 'give_tools_recount_stats_before' );
19
+do_action('give_tools_recount_stats_before');
20 20
 ?>
21 21
 	<div id="poststuff">
22 22
 		<div class="postbox">
23 23
 
24
-			<h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2>
24
+			<h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2>
25 25
 
26 26
 			<div class="inside recount-stats-controls">
27
-				<p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p>
27
+				<p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p>
28 28
 				<form method="post" id="give-tools-recount-form" class="give-export-form">
29 29
 
30
-					<?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
30
+					<?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?>
31 31
 
32 32
 					<select name="give-export-class" id="recount-stats-type">
33
-						<option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option>
34
-						<option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option>
35
-						<option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option>
36
-						<option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option>
37
-						<option data-type="recount-donor-stats" value="Give_Tools_Recount_Donor_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option>
38
-						<option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Payments', 'give' ); ?></option>
39
-						<option data-type="delete-test-donors"   value="Give_Tools_Delete_Donors"><?php esc_html_e( 'Delete Test Donors and Payments', 'give' ); ?></option>
40
-						<option data-type="delete-import-donors"   value="Give_Tools_Import_Donors"><?php esc_html_e( 'Delete Imported Donors and Payments', 'give' ); ?></option>
41
-						<option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option>
33
+						<option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option>
34
+						<option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option>
35
+						<option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option>
36
+						<option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option>
37
+						<option data-type="recount-donor-stats" value="Give_Tools_Recount_Donor_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option>
38
+						<option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Payments', 'give'); ?></option>
39
+						<option data-type="delete-test-donors"   value="Give_Tools_Delete_Donors"><?php esc_html_e('Delete Test Donors and Payments', 'give'); ?></option>
40
+						<option data-type="delete-import-donors"   value="Give_Tools_Import_Donors"><?php esc_html_e('Delete Imported Donors and Payments', 'give'); ?></option>
41
+						<option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option>
42 42
 						<?php
43 43
 						/**
44 44
 						 * Fires in the recount stats selectbox.
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 						 *
48 48
 						 * @since 1.5
49 49
 						 */
50
-						do_action( 'give_recount_tool_options' );
50
+						do_action('give_recount_tool_options');
51 51
 						?>
52 52
 					</select>
53 53
 
@@ -56,34 +56,34 @@  discard block
 block discarded – undo
56 56
 						$args = array(
57 57
 							'class'       => 'tools-form-dropdown-recount-form-select',
58 58
 							'name'        => 'form_id',
59
-							'number'      => - 1,
59
+							'number'      => -1,
60 60
 							'chosen'      => true,
61
-							'placeholder' => __( 'Select Form', 'give' ),
61
+							'placeholder' => __('Select Form', 'give'),
62 62
 						);
63
-						echo Give()->html->forms_dropdown( $args );
63
+						echo Give()->html->forms_dropdown($args);
64 64
 						?>
65 65
 					</span>
66 66
 
67 67
 					<span class="tools-form-dropdown tools-form-dropdown-delete-import-donors" style="display: none">
68 68
 						<label for="delete-import-donors">
69 69
 							<?php
70
-							echo Give()->html->checkbox( array(
70
+							echo Give()->html->checkbox(array(
71 71
 								'name'    => 'delete-import-donors'
72
-							) );
73
-							_e( 'Delete imported WordPress users', 'give' );
72
+							));
73
+							_e('Delete imported WordPress users', 'give');
74 74
 							?>
75 75
 						</label>
76 76
 					</span>
77 77
 
78
-					<input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/>
78
+					<input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/>
79 79
 
80 80
 					<br/>
81 81
 
82 82
 					<span class="give-recount-stats-descriptions">
83
-						<span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span>
84
-						<span id="recount-form"><?php esc_html_e( 'Recalculates the donation and income stats for a specific form.', 'give' ); ?></span>
85
-						<span id="recount-all"><?php esc_html_e( 'Recalculates the earnings and sales stats for all forms.', 'give' ); ?></span>
86
-						<span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span>
83
+						<span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span>
84
+						<span id="recount-form"><?php esc_html_e('Recalculates the donation and income stats for a specific form.', 'give'); ?></span>
85
+						<span id="recount-all"><?php esc_html_e('Recalculates the earnings and sales stats for all forms.', 'give'); ?></span>
86
+						<span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span>
87 87
 						<?php
88 88
 						/**
89 89
 						 * Fires in the recount stats description area.
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 						 *
93 93
 						 * @since 1.5
94 94
 						 */
95
-						do_action( 'give_recount_tool_descriptions' );
95
+						do_action('give_recount_tool_descriptions');
96 96
 						?>
97
-						<span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give' ); ?></span>
98
-						<span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span>
97
+						<span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give'); ?></span>
98
+						<span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span>
99 99
 					</span>
100 100
 
101 101
 					<span class="spinner"></span>
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 				 *
110 110
 				 * @since 1.5
111 111
 				 */
112
-				do_action( 'give_tools_recount_forms' );
112
+				do_action('give_tools_recount_forms');
113 113
 				?>
114 114
 			</div><!-- .inside -->
115 115
 		</div><!-- .postbox -->
@@ -120,4 +120,4 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @since 1.5
122 122
  */
123
-do_action( 'give_tools_recount_stats_after' );
123
+do_action('give_tools_recount_stats_after');
Please login to merge, or discard this patch.
includes/admin/tools/views/html-admin-page-imports.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Admin View: Imports
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if ( ! defined('ABSPATH')) {
7 7
 	exit;
8 8
 } ?>
9 9
 
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 				 *
19 19
 				 * @since 1.8.14
20 20
 				 */
21
-				do_action( 'give_tools_tab_import_content_top' );
21
+				do_action('give_tools_tab_import_content_top');
22 22
 				?>
23 23
 
24 24
 				<table class="widefat Import-options-table give-table">
25 25
 					<thead>
26 26
 					<tr>
27
-						<th scope="col"><?php esc_html_e( 'Import Type', 'give' ); ?></th>
28
-						<th scope="col"><?php esc_html_e( 'Import Options', 'give' ); ?></th>
27
+						<th scope="col"><?php esc_html_e('Import Type', 'give'); ?></th>
28
+						<th scope="col"><?php esc_html_e('Import Options', 'give'); ?></th>
29 29
 					</tr>
30 30
 					</thead>
31 31
 					<tbody>
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 					 *
39 39
 					 * @since 1.8.14
40 40
 					 */
41
-					do_action( 'give_tools_tab_import_table_top' );
41
+					do_action('give_tools_tab_import_table_top');
42 42
 					?>
43 43
 
44 44
 					<tr class="give-Import-pdf-sales-earnings">
45 45
 						<td scope="row" class="row-title">
46 46
 							<h3>
47
-								<span><?php esc_html_e( 'Import Donations', 'give' ); ?></span>
47
+								<span><?php esc_html_e('Import Donations', 'give'); ?></span>
48 48
 							</h3>
49
-							<p><?php esc_html_e( 'Import a CSV of Donations.', 'give' ); ?></p>
49
+							<p><?php esc_html_e('Import a CSV of Donations.', 'give'); ?></p>
50 50
 						</td>
51 51
 						<td>
52
-							<a class="button" href="<?php echo add_query_arg( array( 'importer-type' => 'import_donations' ) ); ?>">
53
-								<?php esc_html_e( 'Import CSV', 'give' ); ?>
52
+							<a class="button" href="<?php echo add_query_arg(array('importer-type' => 'import_donations')); ?>">
53
+								<?php esc_html_e('Import CSV', 'give'); ?>
54 54
 							</a>
55 55
 						</td>
56 56
 					</tr>
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 					<tr class="give-import-core-settings">
59 59
 						<td scope="row" class="row-title">
60 60
 							<h3>
61
-								<span><?php esc_html_e( 'Import Give Settings', 'give' ); ?></span>
61
+								<span><?php esc_html_e('Import Give Settings', 'give'); ?></span>
62 62
 							</h3>
63
-							<p><?php esc_html_e( 'Import Give\'s settings in JSON format.', 'give' ); ?></p>
63
+							<p><?php esc_html_e('Import Give\'s settings in JSON format.', 'give'); ?></p>
64 64
 						</td>
65 65
 						<td>
66
-							<a class="button" href="<?php echo add_query_arg( array( 'importer-type' => 'import_core_setting' ) ); ?>">
67
-								<?php esc_html_e( 'Import JSON', 'give' ); ?>
66
+							<a class="button" href="<?php echo add_query_arg(array('importer-type' => 'import_core_setting')); ?>">
67
+								<?php esc_html_e('Import JSON', 'give'); ?>
68 68
 							</a>
69 69
 						</td>
70 70
 					</tr>
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 					 *
79 79
 					 * @since 1.8.14
80 80
 					 */
81
-					do_action( 'give_tools_tab_import_table_bottom' );
81
+					do_action('give_tools_tab_import_table_bottom');
82 82
 					?>
83 83
 					</tbody>
84 84
 				</table>
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 				 *
90 90
 				 * @since 1.8.14
91 91
 				 */
92
-				do_action( 'give_tools_tab_import_content_bottom' );
92
+				do_action('give_tools_tab_import_content_bottom');
93 93
 				?>
94 94
 
95 95
 			</div>
Please login to merge, or discard this patch.
includes/admin/tools/views/html-admin-page-import-core-settings.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
  * Admin View: Import Core Settings
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if ( ! defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 
10
-if ( ! current_user_can( 'manage_give_settings' ) ) {
10
+if ( ! current_user_can('manage_give_settings')) {
11 11
 	return;
12 12
 }
13 13
 
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * @since 1.8.17
18 18
  */
19
-do_action( 'give_tools_import_core_settings_main_before' );
19
+do_action('give_tools_import_core_settings_main_before');
20 20
 ?>
21 21
 	<div id="poststuff">
22 22
 		<div class="postbox">
23
-			<h1 class="give-importer-h1" align="center"><?php esc_html_e( 'Import Settings', 'give' ); ?></h1>
23
+			<h1 class="give-importer-h1" align="center"><?php esc_html_e('Import Settings', 'give'); ?></h1>
24 24
 			<div class="inside give-tools-setting-page-import give-import-core-settings">
25 25
 				<?php
26 26
 				/**
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 				 *
29 29
 				 * @since 1.8.17
30 30
 				 */
31
-				do_action( 'give_tools_import_core_settings_form_before_start' );
31
+				do_action('give_tools_import_core_settings_form_before_start');
32 32
 				?>
33 33
 				<form method="post" id="give-import-core-settings-form"
34 34
 				      class="give-import-form tools-setting-page-import tools-setting-page-import"
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 					 *
41 41
 					 * @since 1.8.17
42 42
 					 */
43
-					do_action( 'give_tools_import_core_settings_form_start' );
43
+					do_action('give_tools_import_core_settings_form_start');
44 44
 					?>
45 45
 
46 46
 					<?php
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 					 *
50 50
 					 * @since 1.8.17
51 51
 					 */
52
-					do_action( 'give_tools_import_core_settings_form_end' );
52
+					do_action('give_tools_import_core_settings_form_end');
53 53
 					?>
54 54
 				</form>
55 55
 				<?php
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 				 *
59 59
 				 * @since 1.8.17
60 60
 				 */
61
-				do_action( 'give_tools_import_core_settings_form_after_end' );
61
+				do_action('give_tools_import_core_settings_form_after_end');
62 62
 				?>
63 63
 			</div><!-- .inside -->
64 64
 		</div><!-- .postbox -->
@@ -69,4 +69,4 @@  discard block
 block discarded – undo
69 69
  *
70 70
  * @since 1.8.17
71 71
  */
72
-do_action( 'give_tools_import_core_settings_main_after' );
72
+do_action('give_tools_import_core_settings_main_after');
Please login to merge, or discard this patch.
includes/admin/tools/logs/class-sales-logs-list-table.php 1 patch
Spacing   +81 added lines, -81 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,13 +44,13 @@  discard block
 block discarded – undo
44 44
 		global $status, $page;
45 45
 
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
-		add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) );
53
+		add_action('give_log_view_actions', array($this, 'give_forms_filter'));
54 54
 	}
55 55
 
56 56
 	/**
@@ -64,41 +64,41 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
67
+	public function column_default($item, $column_name) {
68 68
 
69
-		$payment = give_get_payment_by( 'id', $item['payment_id'] );
69
+		$payment = give_get_payment_by('id', $item['payment_id']);
70 70
 
71
-		switch ( $column_name ) {
71
+		switch ($column_name) {
72 72
 			case 'form' :
73
-				$form_title = get_the_title( $item[ $column_name ] );
74
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title;
75
-				return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . esc_html( $form_title ). '</a>';
73
+				$form_title = get_the_title($item[$column_name]);
74
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title;
75
+				return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.esc_html($form_title).'</a>';
76 76
 
77 77
 			case 'donor_id' :
78 78
 				return sprintf(
79 79
 					'<a href="%s">%s</a>',
80
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['donor_id'] ) ),
80
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['donor_id'])),
81 81
 					$item['donor_name']
82 82
 				);
83 83
 
84 84
 			case 'amount' :
85
-				return give_currency_filter( give_format_amount( $item['amount'], array( 'sanitize' => false, 'donation_id' => $item['payment_id'] ) ), give_get_payment_currency_code( $item['payment_id'] ) );
85
+				return give_currency_filter(give_format_amount($item['amount'], array('sanitize' => false, 'donation_id' => $item['payment_id'])), give_get_payment_currency_code($item['payment_id']));
86 86
 
87 87
 			case 'status' :
88 88
 
89
-				$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
89
+				$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
90 90
 
91
-				if ( $payment->mode == 'test' ) {
92
-					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . __( 'Test', 'give' ) . '</span>';
91
+				if ($payment->mode == 'test') {
92
+					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.__('Test', 'give').'</span>';
93 93
 				}
94 94
 
95 95
 				return $value;
96 96
 
97 97
 			case 'payment_id' :
98
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>';
98
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>';
99 99
 
100 100
 			default:
101
-				return $item[ $column_name ];
101
+				return $item[$column_name];
102 102
 		}
103 103
 	}
104 104
 
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function get_columns() {
113 113
 		$columns = array(
114
-			'ID'         => __( 'Log ID', 'give' ),
115
-			'donor_id'   => __( 'Donor', 'give' ),
116
-			'form'       => __( 'Form', 'give' ),
117
-			'amount'     => __( 'Donation Amount', 'give' ),
118
-			'status'     => __( 'Status', 'give' ),
119
-			'payment_id' => __( 'Donation ID', 'give' ),
120
-			'date'       => __( 'Date', 'give' ),
114
+			'ID'         => __('Log ID', 'give'),
115
+			'donor_id'   => __('Donor', 'give'),
116
+			'form'       => __('Form', 'give'),
117
+			'amount'     => __('Donation Amount', 'give'),
118
+			'status'     => __('Status', 'give'),
119
+			'payment_id' => __('Donation ID', 'give'),
120
+			'date'       => __('Date', 'give'),
121 121
 		);
122 122
 
123 123
 		return $columns;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @return int Current page number
132 132
 	 */
133 133
 	public function get_paged() {
134
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
134
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
135 135
 	}
136 136
 
137 137
 	/**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @return mixed int If User ID, string If Email/Login
143 143
 	 */
144 144
 	public function get_filtered_user() {
145
-		return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false;
145
+		return isset($_GET['user']) ? absint($_GET['user']) : false;
146 146
 	}
147 147
 
148 148
 	/**
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return int Download ID
154 154
 	 */
155 155
 	public function get_filtered_give_form() {
156
-		return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false;
156
+		return ! empty($_GET['form']) ? absint($_GET['form']) : false;
157 157
 	}
158 158
 
159 159
 	/**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @return string|bool string If search is present, false otherwise
165 165
 	 */
166 166
 	public function get_search() {
167
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
167
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
168 168
 	}
169 169
 
170 170
 
@@ -180,20 +180,20 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @param string $which
182 182
 	 */
183
-	protected function display_tablenav( $which ) {
183
+	protected function display_tablenav($which) {
184 184
 
185
-		if ( 'top' === $which ) {
186
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
185
+		if ('top' === $which) {
186
+			wp_nonce_field('bulk-'.$this->_args['plural']);
187 187
 		}
188 188
 		?>
189
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
189
+		<div class="tablenav <?php echo esc_attr($which); ?>">
190 190
 
191 191
 			<div class="alignleft actions bulkactions">
192
-				<?php $this->bulk_actions( $which ); ?>
192
+				<?php $this->bulk_actions($which); ?>
193 193
 			</div>
194 194
 			<?php
195
-			$this->extra_tablenav( $which );
196
-			$this->pagination( $which );
195
+			$this->extra_tablenav($which);
196
+			$this->pagination($which);
197 197
 			?>
198 198
 
199 199
 			<br class="clear"/>
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
 		$meta_query = array();
219 219
 
220
-		if ( $user ) {
220
+		if ($user) {
221 221
 			// Show only logs from a specific user.
222 222
 			$meta_query[] = array(
223 223
 				'key'   => '_give_log_user_id',
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		}
227 227
 
228 228
 		$search = $this->get_search();
229
-		if ( $search ) {
230
-			if ( is_email( $search ) ) {
229
+		if ($search) {
230
+			if (is_email($search)) {
231 231
 				// This is an email search. We use this to ensure it works for guest users and logged-in users.
232 232
 				$key     = '_give_log_user_info';
233 233
 				$compare = 'LIKE';
@@ -236,32 +236,32 @@  discard block
 block discarded – undo
236 236
 				$key     = '_give_log_user_id';
237 237
 				$compare = 'LIKE';
238 238
 
239
-				if ( ! is_numeric( $search ) ) {
239
+				if ( ! is_numeric($search)) {
240 240
 					// Searching for user by username
241
-					$user = get_user_by( 'login', $search );
241
+					$user = get_user_by('login', $search);
242 242
 
243
-					if ( $user ) {
243
+					if ($user) {
244 244
 						// Found one, set meta value to user's ID.
245 245
 						$search = $user->ID;
246 246
 					} else {
247 247
 						// No user found so let's do a real search query.
248
-						$users = new WP_User_Query( array(
248
+						$users = new WP_User_Query(array(
249 249
 							'search'         => $search,
250
-							'search_columns' => array( 'user_url', 'user_nicename' ),
250
+							'search_columns' => array('user_url', 'user_nicename'),
251 251
 							'number'         => 1,
252 252
 							'fields'         => 'ids',
253
-						) );
253
+						));
254 254
 
255 255
 						$found_user = $users->get_results();
256 256
 
257
-						if ( $found_user ) {
257
+						if ($found_user) {
258 258
 							$search = $found_user[0];
259 259
 						}
260 260
 					}
261 261
 				}
262 262
 			}
263 263
 
264
-			if ( ! $this->file_search ) {
264
+			if ( ! $this->file_search) {
265 265
 				// Meta query only works for non file name search.
266 266
 				$meta_query[] = array(
267 267
 					'key'     => $key,
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @since  1.0
283 283
 	 * @return void
284 284
 	 */
285
-	function bulk_actions( $which = '' ) {
285
+	function bulk_actions($which = '') {
286 286
 		give_log_views();
287 287
 	}
288 288
 
@@ -294,24 +294,24 @@  discard block
 block discarded – undo
294 294
 	 * @return void
295 295
 	 */
296 296
 	public function give_forms_filter() {
297
-		$give_forms = get_posts( array(
297
+		$give_forms = get_posts(array(
298 298
 			'post_type'              => 'give_forms',
299 299
 			'post_status'            => 'any',
300
-			'posts_per_page'         => - 1,
300
+			'posts_per_page'         => -1,
301 301
 			'orderby'                => 'title',
302 302
 			'order'                  => 'ASC',
303 303
 			'fields'                 => 'ids',
304 304
 			'update_post_meta_cache' => false,
305 305
 			'update_post_term_cache' => false,
306
-		) );
306
+		));
307 307
 
308
-		if ( $give_forms ) {
308
+		if ($give_forms) {
309 309
 			echo '<select name="form" id="give-log-form-filter">';
310
-			echo '<option value="0">' . __( 'All', 'give' ) . '</option>';
311
-			foreach ( $give_forms as $form ) {
312
-				$form_title = get_the_title( $form );
313
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title;
314
-				echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>';
310
+			echo '<option value="0">'.__('All', 'give').'</option>';
311
+			foreach ($give_forms as $form) {
312
+				$form_title = get_the_title($form);
313
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title;
314
+				echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>';
315 315
 			}
316 316
 			echo '</select>';
317 317
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
 		$logs_data = array();
333 333
 		$paged     = $this->get_paged();
334
-		$give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null;
334
+		$give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null;
335 335
 		$user      = $this->get_filtered_user();
336 336
 
337 337
 		$log_query = array(
@@ -342,37 +342,37 @@  discard block
 block discarded – undo
342 342
 			'posts_per_page' => $this->per_page,
343 343
 		);
344 344
 
345
-		$cache_key = Give_Cache::get_key( 'get_logs', $log_query );
345
+		$cache_key = Give_Cache::get_key('get_logs', $log_query);
346 346
 
347 347
 		// Return result from cache if exist.
348
-		if ( ! ( $logs_data = Give_Cache::get( $cache_key ) ) ) {
349
-			$logs = $give_logs->get_connected_logs( $log_query );
348
+		if ( ! ($logs_data = Give_Cache::get($cache_key))) {
349
+			$logs = $give_logs->get_connected_logs($log_query);
350 350
 
351
-			if ( $logs ) {
352
-				foreach ( $logs as $log ) {
353
-					$payment_id = give_get_meta( $log->ID, '_give_log_payment_id', true );
351
+			if ($logs) {
352
+				foreach ($logs as $log) {
353
+					$payment_id = give_get_meta($log->ID, '_give_log_payment_id', true);
354 354
 
355 355
 					// Make sure this payment hasn't been deleted.
356
-					if ( get_post( $payment_id ) ) :
357
-						$user_info      = give_get_payment_meta_user_info( $payment_id );
358
-						$payment_amount = give_donation_amount( $payment_id );
356
+					if (get_post($payment_id)) :
357
+						$user_info      = give_get_payment_meta_user_info($payment_id);
358
+						$payment_amount = give_donation_amount($payment_id);
359 359
 
360 360
 						$logs_data[] = array(
361
-							'ID'         => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>',
361
+							'ID'         => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>',
362 362
 							'payment_id' => $payment_id,
363 363
 							'form'       => $log->post_parent,
364 364
 							'amount'     => $payment_amount,
365
-							'donor_id'   => give_get_payment_donor_id( $payment_id ),
366
-							'donor_name' => trim( "{$user_info['first_name']} {$user_info['last_name']}" ),
367
-							'date'       => get_post_field( 'post_date', $payment_id ),
365
+							'donor_id'   => give_get_payment_donor_id($payment_id),
366
+							'donor_name' => trim("{$user_info['first_name']} {$user_info['last_name']}"),
367
+							'date'       => get_post_field('post_date', $payment_id),
368 368
 						);
369 369
 
370 370
 					endif;
371 371
 				}
372 372
 
373 373
 				// Cache results.
374
-				if ( ! empty( $logs_data ) ) {
375
-					Give_Cache::set( $cache_key, $logs_data );
374
+				if ( ! empty($logs_data)) {
375
+					Give_Cache::set($cache_key, $logs_data);
376 376
 				}
377 377
 			}
378 378
 		}
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
 		$columns               = $this->get_columns();
401 401
 		$hidden                = array();
402 402
 		$sortable              = $this->get_sortable_columns();
403
-		$this->_column_headers = array( $columns, $hidden, $sortable );
403
+		$this->_column_headers = array($columns, $hidden, $sortable);
404 404
 		$current_page          = $this->get_pagenum();
405 405
 		$this->items           = $this->get_logs();
406
-		$total_items           = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() );
406
+		$total_items           = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query());
407 407
 
408
-		$this->set_pagination_args( array(
408
+		$this->set_pagination_args(array(
409 409
 				'total_items' => $total_items,
410 410
 				'per_page'    => $this->per_page,
411
-				'total_pages' => ceil( $total_items / $this->per_page ),
411
+				'total_pages' => ceil($total_items / $this->per_page),
412 412
 			)
413 413
 		);
414 414
 	}
Please login to merge, or discard this patch.
includes/admin/tools/class-settings-system-info.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_System_Info' ) ) :
16
+if ( ! class_exists('Give_Settings_System_Info')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_System_Info.
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 		 */
35 35
 		public function __construct() {
36 36
 			$this->id    = 'system-info';
37
-			$this->label = esc_html__( 'System Info', 'give' );
37
+			$this->label = esc_html__('System Info', 'give');
38 38
 
39 39
 			parent::__construct();
40 40
 
41 41
 			// Do not use main form for this tab.
42
-			if ( give_get_current_setting_tab() === $this->id ) {
43
-				add_action( "give-tools_open_form", '__return_empty_string' );
44
-				add_action( "give-tools_close_form", '__return_empty_string' );
42
+			if (give_get_current_setting_tab() === $this->id) {
43
+				add_action("give-tools_open_form", '__return_empty_string');
44
+				add_action("give-tools_close_form", '__return_empty_string');
45 45
 			}
46 46
 		}
47 47
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		 */
54 54
 		public function output() {
55 55
 			$GLOBALS['give_hide_save_button'] = true;
56
-			include_once( 'views/html-admin-page-system-info.php' );
56
+			include_once('views/html-admin-page-system-info.php');
57 57
 		}
58 58
 	}
59 59
 
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-stats.php 1 patch
Spacing   +54 added lines, -54 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
 
@@ -60,59 +60,59 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function get_data() {
62 62
 
63
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
63
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
64 64
 
65
-		if ( $this->step == 1 ) {
66
-			$this->delete_data( 'give_temp_recount_form_stats' );
65
+		if ($this->step == 1) {
66
+			$this->delete_data('give_temp_recount_form_stats');
67 67
 		}
68 68
 
69
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
69
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
70 70
 
71
-		if ( false === $totals ) {
71
+		if (false === $totals) {
72 72
 			$totals = array(
73 73
 				'earnings' => (float) 0,
74 74
 				'sales'    => 0,
75 75
 			);
76
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
76
+			$this->store_data('give_temp_recount_form_stats', $totals);
77 77
 		}
78 78
 
79
-		$args = apply_filters( 'give_recount_form_stats_args', array(
79
+		$args = apply_filters('give_recount_form_stats_args', array(
80 80
 			'give_forms' => $this->form_id,
81 81
 			'number'     => $this->per_step,
82 82
 			'status'     => $accepted_statuses,
83 83
 			'paged'      => $this->step,
84 84
 			'fields'     => 'ids',
85
-		) );
85
+		));
86 86
 
87
-		$payments = new Give_Payments_Query( $args );
87
+		$payments = new Give_Payments_Query($args);
88 88
 		$payments = $payments->get_payments();
89 89
 
90
-		if ( $payments ) {
91
-			foreach ( $payments as $payment ) {
90
+		if ($payments) {
91
+			foreach ($payments as $payment) {
92 92
 
93 93
 				// Ensure acceptable status only.
94
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
94
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
95 95
 					continue;
96 96
 				}
97 97
 
98 98
 				// Ensure only payments for this form are counted.
99
-				if ( $payment->form_id != $this->form_id ) {
99
+				if ($payment->form_id != $this->form_id) {
100 100
 					continue;
101 101
 				}
102 102
 
103
-				$totals['sales'] ++;
103
+				$totals['sales']++;
104 104
 				$totals['earnings'] += $payment->total;
105 105
 
106 106
 			}
107 107
 
108
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
108
+			$this->store_data('give_temp_recount_form_stats', $totals);
109 109
 
110 110
 			return true;
111 111
 		}
112 112
 
113 113
 
114
-		give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
115
-		give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
114
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
115
+		give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
116 116
 
117 117
 		return false;
118 118
 	}
@@ -124,35 +124,35 @@  discard block
 block discarded – undo
124 124
 	 * @return int
125 125
 	 */
126 126
 	public function get_percentage_complete() {
127
-		if ( $this->step == 1 ) {
128
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
127
+		if ($this->step == 1) {
128
+			$this->delete_data('give_recount_total_'.$this->form_id);
129 129
 		}
130 130
 
131
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
132
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
131
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
132
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
133 133
 
134
-		if ( false === $total ) {
134
+		if (false === $total) {
135 135
 			$total = 0;
136
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
136
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
137 137
 				'give_forms' => $this->form_id,
138
-				'number'     => - 1,
138
+				'number'     => -1,
139 139
 				'status'     => $accepted_statuses,
140 140
 				'fields'     => 'ids',
141
-			) );
141
+			));
142 142
 
143
-			$payments = new Give_Payments_Query( $args );
144
-			$total    = count( $payments->get_payments() );
145
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
143
+			$payments = new Give_Payments_Query($args);
144
+			$total    = count($payments->get_payments());
145
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
146 146
 
147 147
 		}
148 148
 
149 149
 		$percentage = 100;
150 150
 
151
-		if ( $total > 0 ) {
152
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
151
+		if ($total > 0) {
152
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
153 153
 		}
154 154
 
155
-		if ( $percentage > 100 ) {
155
+		if ($percentage > 100) {
156 156
 			$percentage = 100;
157 157
 		}
158 158
 
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @param array $request The Form Data passed into the batch processing
168 168
 	 */
169
-	public function set_properties( $request ) {
170
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
169
+	public function set_properties($request) {
170
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
171 171
 	}
172 172
 
173 173
 	/**
@@ -178,31 +178,31 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	public function process_step() {
180 180
 
181
-		if ( ! $this->can_export() ) {
182
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
181
+		if ( ! $this->can_export()) {
182
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
183 183
 		}
184 184
 
185 185
 		$had_data = $this->get_data();
186 186
 
187
-		if ( $had_data ) {
187
+		if ($had_data) {
188 188
 			$this->done = false;
189 189
 
190 190
 			return true;
191 191
 		} else {
192
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
193
-			$this->delete_data( 'give_temp_recount_form_stats' );
192
+			$this->delete_data('give_recount_total_'.$this->form_id);
193
+			$this->delete_data('give_temp_recount_form_stats');
194 194
 			$this->done    = true;
195
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
195
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
196 196
 
197 197
 			return false;
198 198
 		}
199 199
 	}
200 200
 
201 201
 	public function headers() {
202
-		ignore_user_abort( true );
202
+		ignore_user_abort(true);
203 203
 
204
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
205
-			set_time_limit( 0 );
204
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
205
+			set_time_limit(0);
206 206
 		}
207 207
 	}
208 208
 
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @return mixed       Returns the data from the database
232 232
 	 */
233
-	private function get_stored_data( $key ) {
233
+	private function get_stored_data($key) {
234 234
 		global $wpdb;
235
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
235
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
236 236
 
237
-		if ( empty( $value ) ) {
237
+		if (empty($value)) {
238 238
 			return false;
239 239
 		}
240 240
 
241
-		$maybe_json = json_decode( $value );
242
-		if ( ! is_null( $maybe_json ) ) {
243
-			$value = json_decode( $value, true );
241
+		$maybe_json = json_decode($value);
242
+		if ( ! is_null($maybe_json)) {
243
+			$value = json_decode($value, true);
244 244
 		}
245 245
 
246 246
 		return $value;
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return void
258 258
 	 */
259
-	private function store_data( $key, $value ) {
259
+	private function store_data($key, $value) {
260 260
 		global $wpdb;
261 261
 
262
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
262
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
263 263
 
264 264
 		$data = array(
265 265
 			'option_name'  => $key,
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			'%s',
274 274
 		);
275 275
 
276
-		$wpdb->replace( $wpdb->options, $data, $formats );
276
+		$wpdb->replace($wpdb->options, $data, $formats);
277 277
 	}
278 278
 
279 279
 	/**
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @return void
287 287
 	 */
288
-	private function delete_data( $key ) {
288
+	private function delete_data($key) {
289 289
 		global $wpdb;
290
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
290
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
291 291
 	}
292 292
 
293 293
 }
294 294
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +98 added lines, -100 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
 
@@ -80,108 +80,106 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function get_data() {
82 82
 
83
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
84
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
85
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
86
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
83
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
84
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
85
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
86
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
87 87
 
88
-		if ( false === $totals ) {
88
+		if (false === $totals) {
89 89
 			$totals = array();
90 90
 		}
91 91
 
92
-		if ( false === $payment_items ) {
92
+		if (false === $payment_items) {
93 93
 			$payment_items = array();
94 94
 		}
95 95
 
96
-		if ( false === $processed_payments ) {
96
+		if (false === $processed_payments) {
97 97
 			$processed_payments = array();
98 98
 		}
99 99
 
100
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
100
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
101 101
 
102
-		$payments = $this->get_stored_data( 'give_temp_all_payments_data' );
102
+		$payments = $this->get_stored_data('give_temp_all_payments_data');
103 103
 
104
-		if ( empty( $payments ) ) {
105
-			$args = apply_filters( 'give_recount_form_stats_args', array(
104
+		if (empty($payments)) {
105
+			$args = apply_filters('give_recount_form_stats_args', array(
106 106
 				'give_forms' => $all_forms,
107 107
 				'number'     => $this->per_step,
108 108
 				'status'     => $accepted_statuses,
109 109
 				'paged'      => $this->step,
110 110
 				'output'     => 'give_payments',
111
-			) );
111
+			));
112 112
 
113
-			$payments_query = new Give_Payments_Query( $args );
113
+			$payments_query = new Give_Payments_Query($args);
114 114
 			$payments       = $payments_query->get_payments();
115 115
 		}
116 116
 
117
-		if ( ! empty( $payments ) ) {
117
+		if ( ! empty($payments)) {
118 118
 
119 119
 			//Loop through payments
120
-			foreach ( $payments as $payment ) {
120
+			foreach ($payments as $payment) {
121 121
 
122
-				$payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) );
123
-				$payment = new Give_Payment( $payment_id );
122
+				$payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false));
123
+				$payment = new Give_Payment($payment_id);
124 124
 
125 125
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
126
-				if ( in_array( $payment->ID, $processed_payments ) ) {
126
+				if (in_array($payment->ID, $processed_payments)) {
127 127
 					continue;
128 128
 				}
129 129
 
130 130
 				// Verify accepted status.
131
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
131
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
132 132
 					$processed_payments[] = $payment->ID;
133 133
 					continue;
134 134
 				}
135 135
 
136
-				$payment_item = $payment_items[ $payment->ID ];
136
+				$payment_item = $payment_items[$payment->ID];
137 137
 
138
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
138
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
139 139
 
140 140
 				// Must have a form ID.
141
-				if ( empty( $form_id ) ) {
141
+				if (empty($form_id)) {
142 142
 					continue;
143 143
 				}
144 144
 
145 145
 				// Form ID must be within $all_forms array to be validated.
146
-				if ( ! in_array( $form_id, $all_forms ) ) {
146
+				if ( ! in_array($form_id, $all_forms)) {
147 147
 					continue;
148 148
 				}
149 149
 
150 150
 				// Set Sales count
151
-				$totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ?
152
-					++ $totals[ $form_id ]['sales'] :
153
-					1;
151
+				$totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ?
152
+					++$totals[$form_id]['sales'] : 1;
154 153
 
155 154
 				// Set Total Earnings
156
-				$totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ?
157
-					( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) :
158
-					$payment_item['price'];
155
+				$totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ?
156
+					($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price'];
159 157
 
160 158
 				$processed_payments[] = $payment->ID;
161 159
 			}
162 160
 
163 161
 			// Get the list of form ids which does not contain any payment record.
164
-			$remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) );
165
-			foreach ( $remaining_form_ids as $form_id ) {
162
+			$remaining_form_ids = array_diff($all_forms, array_keys($totals));
163
+			foreach ($remaining_form_ids as $form_id) {
166 164
 				//If array key doesn't exist, create it
167
-				if ( ! array_key_exists( $form_id, $totals ) ) {
168
-					$totals[ $form_id ] = array(
165
+				if ( ! array_key_exists($form_id, $totals)) {
166
+					$totals[$form_id] = array(
169 167
 						'sales'    => (int) 0,
170 168
 						'earnings' => (float) 0,
171 169
 					);
172 170
 				}
173 171
 			}
174 172
 
175
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
176
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
173
+			$this->store_data('give_temp_processed_payments', $processed_payments);
174
+			$this->store_data('give_temp_recount_all_stats', $totals);
177 175
 
178 176
 			return true;
179 177
 		}
180 178
 
181 179
 
182
-		foreach ( $totals as $key => $stats ) {
183
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
184
-			give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) );
180
+		foreach ($totals as $key => $stats) {
181
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
182
+			give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings']));
185 183
 		}
186 184
 
187 185
 		return false;
@@ -196,20 +194,20 @@  discard block
 block discarded – undo
196 194
 	 */
197 195
 	public function get_percentage_complete() {
198 196
 
199
-		$total = $this->get_stored_data( 'give_recount_all_total' );
197
+		$total = $this->get_stored_data('give_recount_all_total');
200 198
 
201
-		if ( false === $total ) {
199
+		if (false === $total) {
202 200
 			$this->pre_fetch();
203
-			$total = $this->get_stored_data( 'give_recount_all_total' );
201
+			$total = $this->get_stored_data('give_recount_all_total');
204 202
 		}
205 203
 
206 204
 		$percentage = 100;
207 205
 
208
-		if ( $total > 0 ) {
209
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
206
+		if ($total > 0) {
207
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
210 208
 		}
211 209
 
212
-		if ( $percentage > 100 ) {
210
+		if ($percentage > 100) {
213 211
 			$percentage = 100;
214 212
 		}
215 213
 
@@ -223,8 +221,8 @@  discard block
 block discarded – undo
223 221
 	 *
224 222
 	 * @param array $request The Form Data passed into the batch processing
225 223
 	 */
226
-	public function set_properties( $request ) {
227
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
224
+	public function set_properties($request) {
225
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
228 226
 	}
229 227
 
230 228
 	/**
@@ -235,25 +233,25 @@  discard block
 block discarded – undo
235 233
 	 */
236 234
 	public function process_step() {
237 235
 
238
-		if ( ! $this->can_export() ) {
239
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
236
+		if ( ! $this->can_export()) {
237
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
240 238
 		}
241 239
 
242 240
 		$had_data = $this->get_data();
243 241
 
244
-		if ( $had_data ) {
242
+		if ($had_data) {
245 243
 			$this->done = false;
246 244
 
247 245
 			return true;
248 246
 		} else {
249
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
250
-			$this->delete_data( 'give_recount_all_total' );
251
-			$this->delete_data( 'give_temp_recount_all_stats' );
252
-			$this->delete_data( 'give_temp_payment_items' );
253
-			$this->delete_data( 'give_temp_form_ids' );
254
-			$this->delete_data( 'give_temp_processed_payments' );
247
+			$this->delete_data('give_recount_total_'.$this->form_id);
248
+			$this->delete_data('give_recount_all_total');
249
+			$this->delete_data('give_temp_recount_all_stats');
250
+			$this->delete_data('give_temp_payment_items');
251
+			$this->delete_data('give_temp_form_ids');
252
+			$this->delete_data('give_temp_processed_payments');
255 253
 			$this->done    = true;
256
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
254
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
257 255
 
258 256
 			return false;
259 257
 		}
@@ -263,10 +261,10 @@  discard block
 block discarded – undo
263 261
 	 * Set headers.
264 262
 	 */
265 263
 	public function headers() {
266
-		ignore_user_abort( true );
264
+		ignore_user_abort(true);
267 265
 
268
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
269
-			set_time_limit( 0 );
266
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
267
+			set_time_limit(0);
270 268
 		}
271 269
 	}
272 270
 
@@ -293,70 +291,70 @@  discard block
 block discarded – undo
293 291
 	 */
294 292
 	public function pre_fetch() {
295 293
 
296
-		if ( 1 == $this->step ) {
297
-			$this->delete_data( 'give_temp_recount_all_total' );
298
-			$this->delete_data( 'give_temp_recount_all_stats' );
299
-			$this->delete_data( 'give_temp_payment_items' );
300
-			$this->delete_data( 'give_temp_processed_payments' );
301
-			$this->delete_data( 'give_temp_all_payments_data' );
294
+		if (1 == $this->step) {
295
+			$this->delete_data('give_temp_recount_all_total');
296
+			$this->delete_data('give_temp_recount_all_stats');
297
+			$this->delete_data('give_temp_payment_items');
298
+			$this->delete_data('give_temp_processed_payments');
299
+			$this->delete_data('give_temp_all_payments_data');
302 300
 		}
303 301
 
304
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
305
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
302
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
303
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
306 304
 
307
-		if ( false === $total ) {
305
+		if (false === $total) {
308 306
 
309
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
307
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
310 308
 
311
-			if ( false === $payment_items ) {
309
+			if (false === $payment_items) {
312 310
 				$payment_items = array();
313
-				$this->store_data( 'give_temp_payment_items', $payment_items );
311
+				$this->store_data('give_temp_payment_items', $payment_items);
314 312
 			}
315 313
 
316 314
 			$args = array(
317 315
 				'post_status'    => 'publish',
318 316
 				'post_type'      => 'give_forms',
319
-				'posts_per_page' => - 1,
317
+				'posts_per_page' => -1,
320 318
 				'fields'         => 'ids',
321 319
 			);
322 320
 
323
-			$all_forms = get_posts( $args );
321
+			$all_forms = get_posts($args);
324 322
 
325
-			$this->store_data( 'give_temp_form_ids', $all_forms );
323
+			$this->store_data('give_temp_form_ids', $all_forms);
326 324
 
327
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
325
+			$args = apply_filters('give_recount_form_stats_total_args', array(
328 326
 				'give_forms' => $all_forms,
329 327
 				'number'     => $this->per_step,
330 328
 				'status'     => $accepted_statuses,
331 329
 				'page'       => $this->step,
332 330
 				'output'     => 'payments',
333
-			) );
331
+			));
334 332
 
335
-			$payments_query = new Give_Payments_Query( $args );
333
+			$payments_query = new Give_Payments_Query($args);
336 334
 			$payments       = $payments_query->get_payments();
337 335
 
338
-			$total = wp_count_posts( 'give_payment' )->publish;
336
+			$total = wp_count_posts('give_payment')->publish;
339 337
 
340
-			$this->store_data( 'give_temp_all_payments_data', $payments );
338
+			$this->store_data('give_temp_all_payments_data', $payments);
341 339
 
342
-			if ( $payments ) {
340
+			if ($payments) {
343 341
 
344
-				foreach ( $payments as $payment ) {
342
+				foreach ($payments as $payment) {
345 343
 
346 344
 					$form_id = $payment->form_id;
347 345
 
348 346
 					//If for some reason somehow the form_ID isn't set check payment meta
349
-					if ( empty( $payment->form_id ) ) {
347
+					if (empty($payment->form_id)) {
350 348
 						$payment_meta = $payment->get_meta();
351
-						$form_id      = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
349
+						$form_id      = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
352 350
 					}
353 351
 
354
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
352
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
355 353
 						continue;
356 354
 					}
357 355
 
358
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
359
-						$payment_items[ $payment->ID ] = array(
356
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
357
+						$payment_items[$payment->ID] = array(
360 358
 							'id'         => $form_id,
361 359
 							'payment_id' => $payment->ID,
362 360
 							'price'      => $payment->total,
@@ -364,8 +362,8 @@  discard block
 block discarded – undo
364 362
 					}
365 363
 				}
366 364
 			}
367
-			$this->store_data( 'give_temp_payment_items', $payment_items );
368
-			$this->store_data( 'give_recount_all_total', $total );
365
+			$this->store_data('give_temp_payment_items', $payment_items);
366
+			$this->store_data('give_recount_all_total', $total);
369 367
 		}
370 368
 
371 369
 	}
@@ -379,17 +377,17 @@  discard block
 block discarded – undo
379 377
 	 *
380 378
 	 * @return mixed       Returns the data from the database
381 379
 	 */
382
-	private function get_stored_data( $key ) {
380
+	private function get_stored_data($key) {
383 381
 		global $wpdb;
384
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
385
-		if ( empty( $value ) ) {
382
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
383
+		if (empty($value)) {
386 384
 			return false;
387 385
 		}
388 386
 
389
-		$maybe_json = json_decode( $value );
387
+		$maybe_json = json_decode($value);
390 388
 
391
-		if ( ! is_null( $maybe_json ) ) {
392
-			$value = json_decode( $value, true );
389
+		if ( ! is_null($maybe_json)) {
390
+			$value = json_decode($value, true);
393 391
 		}
394 392
 
395 393
 		return $value;
@@ -405,10 +403,10 @@  discard block
 block discarded – undo
405 403
 	 *
406 404
 	 * @return void
407 405
 	 */
408
-	private function store_data( $key, $value ) {
406
+	private function store_data($key, $value) {
409 407
 		global $wpdb;
410 408
 
411
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
409
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
412 410
 
413 411
 		$data = array(
414 412
 			'option_name'  => $key,
@@ -422,7 +420,7 @@  discard block
 block discarded – undo
422 420
 			'%s',
423 421
 		);
424 422
 
425
-		$wpdb->replace( $wpdb->options, $data, $formats );
423
+		$wpdb->replace($wpdb->options, $data, $formats);
426 424
 	}
427 425
 
428 426
 	/**
@@ -434,9 +432,9 @@  discard block
 block discarded – undo
434 432
 	 *
435 433
 	 * @return void
436 434
 	 */
437
-	private function delete_data( $key ) {
435
+	private function delete_data($key) {
438 436
 		global $wpdb;
439
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
437
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
440 438
 	}
441 439
 
442 440
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +74 added lines, -74 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,40 +53,40 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function get_data() {
55 55
 
56
-		$donor    = new Give_Donor( $this->customer_id );
57
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id );
56
+		$donor    = new Give_Donor($this->customer_id);
57
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id);
58 58
 
59
-		$offset     = ( $this->step - 1 ) * $this->per_step;
60
-		$step_items = array_slice( $payments, $offset, $this->per_step );
59
+		$offset     = ($this->step - 1) * $this->per_step;
60
+		$step_items = array_slice($payments, $offset, $this->per_step);
61 61
 
62
-		if ( count( $step_items ) > 0 ) {
63
-			$pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
62
+		if (count($step_items) > 0) {
63
+			$pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
64 64
 			$step_total    = 0;
65 65
 
66
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id );
66
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id);
67 67
 
68
-			foreach ( $step_items as $payment ) {
69
-				$payment = get_post( $payment->ID );
68
+			foreach ($step_items as $payment) {
69
+				$payment = get_post($payment->ID);
70 70
 
71
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
71
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
72 72
 
73
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id );
73
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$donor->id);
74 74
 					$missing_payments[] = $payment->ID;
75
-					$this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments );
75
+					$this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments);
76 76
 
77 77
 					continue;
78 78
 				}
79 79
 
80 80
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
81
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
81
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
82 82
 
83
-				if ( true === $should_process_payment ) {
83
+				if (true === $should_process_payment) {
84 84
 
85 85
 					$found_payment_ids[] = $payment->ID;
86 86
 
87
-					if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
88
-						$payment_amount = give_donation_amount( $payment->ID );
89
-						$step_total     += $payment_amount;
87
+					if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
88
+						$payment_amount = give_donation_amount($payment->ID);
89
+						$step_total += $payment_amount;
90 90
 					}
91 91
 
92 92
 				}
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 			}
95 95
 
96 96
 			$updated_total = $pending_total + $step_total;
97
-			$this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total );
98
-			$this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids );
97
+			$this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total);
98
+			$this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids);
99 99
 
100 100
 			return true;
101 101
 		}
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function get_percentage_complete() {
114 114
 
115
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id );
116
-		$total    = count( $payments );
115
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id);
116
+		$total    = count($payments);
117 117
 
118 118
 		$percentage = 100;
119 119
 
120
-		if ( $total > 0 ) {
121
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
120
+		if ($total > 0) {
121
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
122 122
 		}
123 123
 
124
-		if ( $percentage > 100 ) {
124
+		if ($percentage > 100) {
125 125
 			$percentage = 100;
126 126
 		}
127 127
 
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $request The Form Data passed into the batch processing
137 137
 	 */
138
-	public function set_properties( $request ) {
139
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
138
+	public function set_properties($request) {
139
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
140 140
 	}
141 141
 
142 142
 	/**
@@ -147,63 +147,63 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function process_step() {
149 149
 
150
-		if ( ! $this->can_export() ) {
151
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
150
+		if ( ! $this->can_export()) {
151
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
152 152
 		}
153 153
 
154 154
 		$had_data = $this->get_data();
155 155
 
156
-		if ( $had_data ) {
156
+		if ($had_data) {
157 157
 			$this->done = false;
158 158
 
159 159
 			return true;
160 160
 		} else {
161
-			$donor       = new Give_Donor( $this->customer_id );
162
-			$payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() );
163
-			$this->delete_data( 'give_stats_found_payments_' . $donor->id );
161
+			$donor       = new Give_Donor($this->customer_id);
162
+			$payment_ids = get_option('give_stats_found_payments_'.$donor->id, array());
163
+			$this->delete_data('give_stats_found_payments_'.$donor->id);
164 164
 
165
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) );
165
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array()));
166 166
 
167 167
 			// Find non-existing payments (deleted) and total up the donation count
168 168
 			$purchase_count = 0;
169
-			foreach ( $payment_ids as $key => $payment_id ) {
170
-				if ( in_array( $payment_id, $removed_payments ) ) {
171
-					unset( $payment_ids[ $key ] );
169
+			foreach ($payment_ids as $key => $payment_id) {
170
+				if (in_array($payment_id, $removed_payments)) {
171
+					unset($payment_ids[$key]);
172 172
 					continue;
173 173
 				}
174 174
 
175
-				$payment = get_post( $payment_id );
176
-				if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
177
-					$purchase_count ++;
175
+				$payment = get_post($payment_id);
176
+				if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
177
+					$purchase_count++;
178 178
 				}
179 179
 			}
180 180
 
181
-			$this->delete_data( 'give_stats_missing_payments' . $donor->id );
181
+			$this->delete_data('give_stats_missing_payments'.$donor->id);
182 182
 
183
-			$pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
184
-			$this->delete_data( 'give_stats_donor_pending_total' . $donor->id );
185
-			$this->delete_data( 'give_recount_donor_stats_' . $donor->id );
186
-			$this->delete_data( 'give_recount_donor_payments_' . $this->customer_id );
183
+			$pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
184
+			$this->delete_data('give_stats_donor_pending_total'.$donor->id);
185
+			$this->delete_data('give_recount_donor_stats_'.$donor->id);
186
+			$this->delete_data('give_recount_donor_payments_'.$this->customer_id);
187 187
 
188
-			$payment_ids = implode( ',', $payment_ids );
189
-			$donor->update( array(
188
+			$payment_ids = implode(',', $payment_ids);
189
+			$donor->update(array(
190 190
 				'payment_ids'    => $payment_ids,
191 191
 				'purchase_count' => $purchase_count,
192 192
 				'purchase_value' => $pending_total,
193
-			) );
193
+			));
194 194
 
195 195
 			$this->done    = true;
196
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
196
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
197 197
 
198 198
 			return false;
199 199
 		}
200 200
 	}
201 201
 
202 202
 	public function headers() {
203
-		ignore_user_abort( true );
203
+		ignore_user_abort(true);
204 204
 
205
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
206
-			set_time_limit( 0 );
205
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
206
+			set_time_limit(0);
207 207
 		}
208 208
 	}
209 209
 
@@ -230,26 +230,26 @@  discard block
 block discarded – undo
230 230
 	 * @return void
231 231
 	 */
232 232
 	public function pre_fetch() {
233
-		if ( $this->step === 1 ) {
234
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
233
+		if ($this->step === 1) {
234
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
235 235
 
236 236
 			// Before we start, let's zero out the customer's data
237
-			$donor = new Give_Donor( $this->customer_id );
238
-			$donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) );
237
+			$donor = new Give_Donor($this->customer_id);
238
+			$donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0));
239 239
 
240
-			$attached_payment_ids = explode( ',', $donor->payment_ids );
240
+			$attached_payment_ids = explode(',', $donor->payment_ids);
241 241
 
242 242
 			$attached_args = array(
243 243
 				'post__in' => $attached_payment_ids,
244
-				'number'   => - 1,
244
+				'number'   => -1,
245 245
 				'status'   => $allowed_payment_status,
246 246
 			);
247 247
 
248
-			$attached_payments = give_get_payments( $attached_args );
248
+			$attached_payments = give_get_payments($attached_args);
249 249
 
250 250
 			$unattached_args = array(
251 251
 				'post__not_in' => $attached_payment_ids,
252
-				'number'       => - 1,
252
+				'number'       => -1,
253 253
 				'status'       => $allowed_payment_status,
254 254
 				'meta_query'   => array(
255 255
 					array(
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 				),
260 260
 			);
261 261
 
262
-			$unattached_payments = give_get_payments( $unattached_args );
262
+			$unattached_payments = give_get_payments($unattached_args);
263 263
 
264
-			$payments = array_merge( $attached_payments, $unattached_payments );
264
+			$payments = array_merge($attached_payments, $unattached_payments);
265 265
 
266
-			$this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments );
266
+			$this->store_data('give_recount_donor_payments_'.$donor->id, $payments);
267 267
 		}
268 268
 	}
269 269
 
@@ -276,17 +276,17 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return mixed       Returns the data from the database
278 278
 	 */
279
-	private function get_stored_data( $key ) {
279
+	private function get_stored_data($key) {
280 280
 		global $wpdb;
281
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
281
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
282 282
 
283
-		if ( empty( $value ) ) {
283
+		if (empty($value)) {
284 284
 			return false;
285 285
 		}
286 286
 
287
-		$maybe_json = json_decode( $value );
288
-		if ( ! is_null( $maybe_json ) ) {
289
-			$value = json_decode( $value, true );
287
+		$maybe_json = json_decode($value);
288
+		if ( ! is_null($maybe_json)) {
289
+			$value = json_decode($value, true);
290 290
 		}
291 291
 
292 292
 		return $value;
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @return void
304 304
 	 */
305
-	private function store_data( $key, $value ) {
305
+	private function store_data($key, $value) {
306 306
 		global $wpdb;
307 307
 
308
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
308
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
309 309
 
310 310
 		$data = array(
311 311
 			'option_name'  => $key,
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 			'%s',
320 320
 		);
321 321
 
322
-		$wpdb->replace( $wpdb->options, $data, $formats );
322
+		$wpdb->replace($wpdb->options, $data, $formats);
323 323
 	}
324 324
 
325 325
 	/**
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 	 *
332 332
 	 * @return void
333 333
 	 */
334
-	private function delete_data( $key ) {
334
+	private function delete_data($key) {
335 335
 		global $wpdb;
336
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
336
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
337 337
 	}
338 338
 
339 339
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-test-transactions.php 1 patch
Spacing   +48 added lines, -48 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,19 +53,19 @@  discard block
 block discarded – undo
53 53
 	 * @return array|bool $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids' );
56
+		$items = $this->get_stored_data('give_temp_delete_test_ids');
57 57
 
58
-		if ( ! is_array( $items ) ) {
58
+		if ( ! is_array($items)) {
59 59
 			return false;
60 60
 		}
61 61
 
62
-		$offset     = ( $this->step - 1 ) * $this->per_step;
63
-		$step_items = array_slice( $items, $offset, $this->per_step );
62
+		$offset     = ($this->step - 1) * $this->per_step;
63
+		$step_items = array_slice($items, $offset, $this->per_step);
64 64
 
65
-		if ( $step_items ) {
66
-			foreach ( $step_items as $item ) {
65
+		if ($step_items) {
66
+			foreach ($step_items as $item) {
67 67
 				// Delete the main payment.
68
-				give_delete_donation( absint( $item['id'] ) );
68
+				give_delete_donation(absint($item['id']));
69 69
 			}
70 70
 			return true;
71 71
 		}
@@ -81,16 +81,16 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function get_percentage_complete() {
83 83
 
84
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids', false );
85
-		$total = count( $items );
84
+		$items = $this->get_stored_data('give_temp_delete_test_ids', false);
85
+		$total = count($items);
86 86
 
87 87
 		$percentage = 100;
88 88
 
89
-		if ( $total > 0 ) {
90
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
89
+		if ($total > 0) {
90
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
91 91
 		}
92 92
 
93
-		if ( $percentage > 100 ) {
93
+		if ($percentage > 100) {
94 94
 			$percentage = 100;
95 95
 		}
96 96
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @param array $request The Form Data passed into the batch processing
106 106
 	 */
107
-	public function set_properties( $request ) {
107
+	public function set_properties($request) {
108 108
 	}
109 109
 
110 110
 	/**
@@ -115,29 +115,29 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function process_step() {
117 117
 
118
-		if ( ! $this->can_export() ) {
119
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
118
+		if ( ! $this->can_export()) {
119
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
120 120
 		}
121 121
 
122 122
 		$had_data = $this->get_data();
123 123
 
124
-		if ( $had_data ) {
124
+		if ($had_data) {
125 125
 			$this->done = false;
126 126
 
127 127
 			return true;
128 128
 		} else {
129
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
130
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
129
+			update_option('give_earnings_total', give_get_total_earnings(true));
130
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
131 131
 
132
-			$this->delete_data( 'give_temp_delete_test_ids' );
132
+			$this->delete_data('give_temp_delete_test_ids');
133 133
 
134 134
 			// Reset the sequential order numbers
135
-			if ( give_get_option( 'enable_sequential' ) ) {
136
-				delete_option( 'give_last_payment_number' );
135
+			if (give_get_option('enable_sequential')) {
136
+				delete_option('give_last_payment_number');
137 137
 			}
138 138
 
139 139
 			$this->done    = true;
140
-			$this->message = __( 'Test transactions successfully deleted.', 'give' );
140
+			$this->message = __('Test transactions successfully deleted.', 'give');
141 141
 
142 142
 			return false;
143 143
 		}
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
 	 * Headers
148 148
 	 */
149 149
 	public function headers() {
150
-		ignore_user_abort( true );
150
+		ignore_user_abort(true);
151 151
 
152
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
153
-			set_time_limit( 0 );
152
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
153
+			set_time_limit(0);
154 154
 		}
155 155
 	}
156 156
 
@@ -174,27 +174,27 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	public function pre_fetch() {
176 176
 
177
-		if ( $this->step == 1 ) {
178
-			$this->delete_data( 'give_temp_delete_test_ids' );
177
+		if ($this->step == 1) {
178
+			$this->delete_data('give_temp_delete_test_ids');
179 179
 		}
180 180
 
181
-		$items = get_option( 'give_temp_delete_test_ids', false );
181
+		$items = get_option('give_temp_delete_test_ids', false);
182 182
 
183
-		if ( false === $items ) {
183
+		if (false === $items) {
184 184
 			$items = array();
185 185
 
186
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
186
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
187 187
 				'post_status' => 'any',
188
-				'number'      => - 1,
188
+				'number'      => -1,
189 189
 				'meta_key'    => '_give_payment_mode',
190 190
 				'meta_value'  => 'test'
191
-			) );
191
+			));
192 192
 
193
-			$posts    = new Give_Payments_Query( $args );
193
+			$posts    = new Give_Payments_Query($args);
194 194
 			$payments = $posts->get_payments();
195 195
 
196 196
 			/* @var Give_Payment $payment */
197
-			foreach ( $payments as $payment ) {
197
+			foreach ($payments as $payment) {
198 198
 				$items[] = array(
199 199
 					'id'   => (int) $payment->ID,
200 200
 					'type' => 'give_payment',
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 			
204 204
 			// Allow filtering of items to remove with an unassociative array for each item.
205 205
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method.
206
-			$items = apply_filters( 'give_delete_test_items', $items );
206
+			$items = apply_filters('give_delete_test_items', $items);
207 207
 
208
-			$this->store_data( 'give_temp_delete_test_ids', $items );
208
+			$this->store_data('give_temp_delete_test_ids', $items);
209 209
 		}
210 210
 
211 211
 	}
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
 	 *
220 220
 	 * @return mixed       Returns the data from the database
221 221
 	 */
222
-	private function get_stored_data( $key ) {
222
+	private function get_stored_data($key) {
223 223
 		global $wpdb;
224
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
224
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
225 225
 
226
-		if ( empty( $value ) ) {
226
+		if (empty($value)) {
227 227
 			return false;
228 228
 		}
229 229
 
230
-		$maybe_json = json_decode( $value );
231
-		if ( ! is_null( $maybe_json ) ) {
232
-			$value = json_decode( $value, true );
230
+		$maybe_json = json_decode($value);
231
+		if ( ! is_null($maybe_json)) {
232
+			$value = json_decode($value, true);
233 233
 		}
234 234
 
235 235
 		return $value;
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @return void
247 247
 	 */
248
-	private function store_data( $key, $value ) {
248
+	private function store_data($key, $value) {
249 249
 		global $wpdb;
250 250
 
251
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
251
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
252 252
 
253 253
 		$data = array(
254 254
 			'option_name'  => $key,
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 			'%s',
263 263
 		);
264 264
 
265
-		$wpdb->replace( $wpdb->options, $data, $formats );
265
+		$wpdb->replace($wpdb->options, $data, $formats);
266 266
 	}
267 267
 
268 268
 	/**
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return void
276 276
 	 */
277
-	private function delete_data( $key ) {
277
+	private function delete_data($key) {
278 278
 		global $wpdb;
279
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
279
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
280 280
 	}
281 281
 
282 282
 }
Please login to merge, or discard this patch.