Completed
Pull Request — master (#745)
by
unknown
34:47 queued 15:03
created
includes/admin/reporting/export/class-batch-export.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) exit;
15
+if ( ! defined('ABSPATH')) exit;
16 16
 
17 17
 /**
18 18
  * Give_Batch_Export Class
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 	 * @param $_step int The step to process
105 105
 	 * @since 1.5
106 106
 	 */
107
-	public function __construct( $_step = 1 ) {
107
+	public function __construct($_step = 1) {
108 108
 
109 109
 		$upload_dir       = wp_upload_dir();
110 110
 		$this->filetype   = '.csv';
111
-		$this->filename   = 'give-' . $this->export_type . $this->filetype;
112
-		$this->file       = trailingslashit( $upload_dir['basedir'] ) . $this->filename;
111
+		$this->filename   = 'give-'.$this->export_type.$this->filetype;
112
+		$this->file       = trailingslashit($upload_dir['basedir']).$this->filename;
113 113
 
114
-		if ( ! is_writeable( $upload_dir['basedir'] ) ) {
114
+		if ( ! is_writeable($upload_dir['basedir'])) {
115 115
 			$this->is_writable = false;
116 116
 		}
117 117
 
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function process_step() {
129 129
 
130
-		if ( ! $this->can_export() ) {
131
-			wp_die( __( 'You do not have permission to export data.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
130
+		if ( ! $this->can_export()) {
131
+			wp_die(__('You do not have permission to export data.', 'give'), __('Error', 'give'), array('response' => 403));
132 132
 		}
133 133
 
134
-		if( $this->step < 2 ) {
134
+		if ($this->step < 2) {
135 135
 
136 136
 			// Make sure we start with a fresh file on step 1
137
-			@unlink( $this->file );
137
+			@unlink($this->file);
138 138
 			$this->print_csv_cols();
139 139
 		}
140 140
 
141 141
 		$rows = $this->print_csv_rows();
142 142
 
143
-		if( $rows ) {
143
+		if ($rows) {
144 144
 			return true;
145 145
 		} else {
146 146
 			return false;
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 		$col_data = '';
161 161
 		$cols = $this->get_csv_cols();
162 162
 		$i = 1;
163
-		foreach( $cols as $col_id => $column ) {
164
-			$col_data .= '"' . addslashes( $column ) . '"';
165
-			$col_data .= $i == count( $cols ) ? '' : ',';
163
+		foreach ($cols as $col_id => $column) {
164
+			$col_data .= '"'.addslashes($column).'"';
165
+			$col_data .= $i == count($cols) ? '' : ',';
166 166
 			$i++;
167 167
 		}
168 168
 		$col_data .= "\r\n";
169 169
 
170
-		$this->stash_step_data( $col_data );
170
+		$this->stash_step_data($col_data);
171 171
 
172 172
 		return $col_data;
173 173
 
@@ -186,23 +186,23 @@  discard block
 block discarded – undo
186 186
 		$data     = $this->get_data();
187 187
 		$cols     = $this->get_csv_cols();
188 188
 
189
-		if( $data ) {
189
+		if ($data) {
190 190
 
191 191
 			// Output each row
192
-			foreach ( $data as $row ) {
192
+			foreach ($data as $row) {
193 193
 				$i = 1;
194
-				foreach ( $row as $col_id => $column ) {
194
+				foreach ($row as $col_id => $column) {
195 195
 					// Make sure the column is valid
196
-					if ( array_key_exists( $col_id, $cols ) ) {
197
-						$row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"';
198
-						$row_data .= $i == count( $cols ) ? '' : ',';
196
+					if (array_key_exists($col_id, $cols)) {
197
+						$row_data .= '"'.addslashes(preg_replace("/\"/", "'", $column)).'"';
198
+						$row_data .= $i == count($cols) ? '' : ',';
199 199
 						$i++;
200 200
 					}
201 201
 				}
202 202
 				$row_data .= "\r\n";
203 203
 			}
204 204
 
205
-			$this->stash_step_data( $row_data );
205
+			$this->stash_step_data($row_data);
206 206
 
207 207
 			return $row_data;
208 208
 		}
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
 
231 231
 		$file = '';
232 232
 
233
-		if ( @file_exists( $this->file ) ) {
233
+		if (@file_exists($this->file)) {
234 234
 
235
-			if ( ! is_writeable( $this->file ) ) {
235
+			if ( ! is_writeable($this->file)) {
236 236
 				$this->is_writable = false;
237 237
 			}
238 238
 
239
-			$file = @file_get_contents( $this->file );
239
+			$file = @file_get_contents($this->file);
240 240
 
241 241
 		} else {
242 242
 
243
-			@file_put_contents( $this->file, '' );
244
-			@chmod( $this->file, 0664 );
243
+			@file_put_contents($this->file, '');
244
+			@chmod($this->file, 0664);
245 245
 
246 246
 		}
247 247
 
@@ -255,18 +255,18 @@  discard block
 block discarded – undo
255 255
 	 * @param $data string The data to add to the file
256 256
 	 * @return void
257 257
 	 */
258
-	protected function stash_step_data( $data = '' ) {
258
+	protected function stash_step_data($data = '') {
259 259
 
260 260
 		$file = $this->get_file();
261 261
 		$file .= $data;
262
-		@file_put_contents( $this->file, $file );
262
+		@file_put_contents($this->file, $file);
263 263
 
264 264
 		// If we have no rows after this step, mark it as an empty export
265
-		$file_rows    = file( $this->file, FILE_SKIP_EMPTY_LINES);
265
+		$file_rows    = file($this->file, FILE_SKIP_EMPTY_LINES);
266 266
 		$default_cols = $this->get_csv_cols();
267
-		$default_cols = empty( $default_cols ) ? 0 : 1;
267
+		$default_cols = empty($default_cols) ? 0 : 1;
268 268
 
269
-		$this->is_empty = count( $file_rows ) == $default_cols ? true : false;
269
+		$this->is_empty = count($file_rows) == $default_cols ? true : false;
270 270
 
271 271
 	}
272 272
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
 		$file = $this->get_file();
286 286
 
287
-		@unlink( $this->file );
287
+		@unlink($this->file);
288 288
 
289 289
 		echo $file;
290 290
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @since 1.5
298 298
 	 * @param array $request The Form Data passed into the batch processing
299 299
 	 */
300
-	public function set_properties( $request ) {}
300
+	public function set_properties($request) {}
301 301
 
302 302
 	/**
303 303
 	 * Allow for prefetching of data for the remainder of the exporter
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) exit;
13
+if ( ! defined( 'ABSPATH' ) ) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * Give_API_V1 Class
Please login to merge, or discard this patch.
includes/admin/reporting/tools.php 1 patch
Spacing   +27 added lines, -27 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
 
@@ -22,68 +22,68 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_tools_recount_stats_display() {
24 24
 
25
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
25
+	if ( ! current_user_can('manage_give_settings')) {
26 26
 		return;
27 27
 	}
28 28
 
29
-	do_action( 'give_tools_recount_stats_before' );
29
+	do_action('give_tools_recount_stats_before');
30 30
 	?>
31 31
 	<div id="poststuff">
32 32
 		<div class="postbox">
33 33
 
34
-			<h2 class="hndle ui-sortable-handle"><span><?php _e( 'Recount Stats', 'give' ); ?></span></h2>
34
+			<h2 class="hndle ui-sortable-handle"><span><?php _e('Recount Stats', 'give'); ?></span></h2>
35 35
 
36 36
 			<div class="inside recount-stats-controls">
37
-				<p><?php _e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p>
37
+				<p><?php _e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p>
38 38
 				<form method="post" id="give-tools-recount-form" class="give-export-form">
39 39
 
40
-					<?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
40
+					<?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?>
41 41
 
42 42
 					<select name="give-export-class" id="recount-stats-type">
43
-						<option value="0" selected="selected" disabled="disabled"><?php _e( 'Please select an option', 'give' ); ?></option>
44
-						<option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php _e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option>
45
-						<option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php _e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option>
46
-						<option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php _e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option>
47
-						<option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php _e( 'Recalculate Donor Statistics', 'give' ); ?></option>
48
-						<option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php _e( 'Delete Test Transactions', 'give' ); ?></option>
49
-						<option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php _e( 'Delete All Data', 'give' ); ?></option>
50
-						<?php do_action( 'give_recount_tool_options' ); ?>
43
+						<option value="0" selected="selected" disabled="disabled"><?php _e('Please select an option', 'give'); ?></option>
44
+						<option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php _e('Recalculate Total Donation Income Amount', 'give'); ?></option>
45
+						<option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php _e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option>
46
+						<option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php _e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option>
47
+						<option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php _e('Recalculate Donor Statistics', 'give'); ?></option>
48
+						<option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php _e('Delete Test Transactions', 'give'); ?></option>
49
+						<option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php _e('Delete All Data', 'give'); ?></option>
50
+						<?php do_action('give_recount_tool_options'); ?>
51 51
 					</select>
52 52
 
53 53
 					<span id="tools-form-dropdown" style="display: none">
54 54
 						<?php
55 55
 						$args = array(
56 56
 							'name'   => 'form_id',
57
-							'number' => - 1,
57
+							'number' => -1,
58 58
 							'chosen' => true,
59 59
 						);
60
-						echo Give()->html->forms_dropdown( $args );
60
+						echo Give()->html->forms_dropdown($args);
61 61
 						?>
62 62
 					</span>
63 63
 
64
-					<input type="submit" id="recount-stats-submit" value="<?php _e( 'Submit', 'give' ); ?>" class="button-secondary"/>
64
+					<input type="submit" id="recount-stats-submit" value="<?php _e('Submit', 'give'); ?>" class="button-secondary"/>
65 65
 
66 66
 					<br/>
67 67
 
68 68
 					<span class="give-recount-stats-descriptions">
69
-						<span id="recount-stats"><?php _e( 'Recalculates the overall donation income amount.', 'give' ); ?></span>
70
-						<span id="recount-form"><?php printf( __( 'Recalculates the donation and income stats for a specific %s.', 'give' ), give_get_forms_label_singular( true ) ); ?></span>
71
-						<span id="recount-all"><?php printf( __( 'Recalculates the earnings and sales stats for all %s.', 'give' ), give_get_forms_label_plural( true ) ); ?></span>
72
-						<span id="recount-customer-stats"><?php _e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span>
73
-						<?php do_action( 'give_recount_tool_descriptions' ); ?>
74
-						<span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST payment records, donors, and related log entries.', 'give' ); ?></span>
75
-						<span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL transaction records, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span>
69
+						<span id="recount-stats"><?php _e('Recalculates the overall donation income amount.', 'give'); ?></span>
70
+						<span id="recount-form"><?php printf(__('Recalculates the donation and income stats for a specific %s.', 'give'), give_get_forms_label_singular(true)); ?></span>
71
+						<span id="recount-all"><?php printf(__('Recalculates the earnings and sales stats for all %s.', 'give'), give_get_forms_label_plural(true)); ?></span>
72
+						<span id="recount-customer-stats"><?php _e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span>
73
+						<?php do_action('give_recount_tool_descriptions'); ?>
74
+						<span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST payment records, donors, and related log entries.', 'give'); ?></span>
75
+						<span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL transaction records, donors, and related log entries regardless of test or live mode.', 'give'); ?></span>
76 76
 					</span>
77 77
 
78 78
 					<span class="spinner"></span>
79 79
 
80 80
 				</form>
81
-				<?php do_action( 'give_tools_recount_forms' ); ?>
81
+				<?php do_action('give_tools_recount_forms'); ?>
82 82
 			</div><!-- .inside -->
83 83
 		</div><!-- .postbox -->
84 84
 	</div><!-- #poststuff -->
85 85
 	<?php
86
-	do_action( 'give_tools_recount_stats_after' );
86
+	do_action('give_tools_recount_stats_after');
87 87
 }
88 88
 
89
-add_action( 'give_reports_tab_tools', 'give_tools_recount_stats_display' );
89
+add_action('give_reports_tab_tools', 'give_tools_recount_stats_display');
Please login to merge, or discard this patch.
admin/reporting/tools/class-give-tools-recount-single-customer-stats.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -188,8 +188,8 @@
 block discarded – undo
188 188
 
189 189
 			$payment_ids = implode( ',', $payment_ids );
190 190
 			$customer->update( array( 'payment_ids'    => $payment_ids,
191
-			                          'purchase_count' => $purchase_count,
192
-			                          'purchase_value' => $pending_total
191
+									  'purchase_count' => $purchase_count,
192
+									  'purchase_value' => $pending_total
193 193
 			) );
194 194
 
195 195
 			$this->done    = true;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 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
 
@@ -54,39 +54,39 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function get_data() {
56 56
 
57
-		$customer = new Give_Customer( $this->customer_id );
58
-		$payments = $this->get_stored_data( 'give_recount_customer_payments_' . $customer->id, array() );
57
+		$customer = new Give_Customer($this->customer_id);
58
+		$payments = $this->get_stored_data('give_recount_customer_payments_'.$customer->id, array());
59 59
 
60
-		$offset     = ( $this->step - 1 ) * $this->per_step;
61
-		$step_items = array_slice( $payments, $offset, $this->per_step );
60
+		$offset     = ($this->step - 1) * $this->per_step;
61
+		$step_items = array_slice($payments, $offset, $this->per_step);
62 62
 
63
-		if ( count( $step_items ) > 0 ) {
64
-			$pending_total = (float) $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 );
63
+		if (count($step_items) > 0) {
64
+			$pending_total = (float) $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0);
65 65
 			$step_total    = 0;
66 66
 
67
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $customer->id, array() );
67
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$customer->id, array());
68 68
 
69
-			foreach ( $step_items as $payment ) {
70
-				$payment = get_post( $payment->ID );
69
+			foreach ($step_items as $payment) {
70
+				$payment = get_post($payment->ID);
71 71
 
72
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
72
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
73 73
 
74
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $customer->id, array() );
74
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$customer->id, array());
75 75
 					$missing_payments[] = $payment->ID;
76
-					$this->store_data( 'give_stats_missing_payments' . $customer->id, $missing_payments );
76
+					$this->store_data('give_stats_missing_payments'.$customer->id, $missing_payments);
77 77
 
78 78
 					continue;
79 79
 				}
80 80
 
81 81
 				$should_process_payment = 'publish' == $payment->post_status || 'revoked' == $payment->post_status ? true : false;
82
-				$should_process_payment = apply_filters( 'give_customer_recount_should_process_payment', $should_process_payment, $payment );
82
+				$should_process_payment = apply_filters('give_customer_recount_should_process_payment', $should_process_payment, $payment);
83 83
 
84
-				if ( true === $should_process_payment ) {
84
+				if (true === $should_process_payment) {
85 85
 
86 86
 					$found_payment_ids[] = $payment->ID;
87 87
 
88
-					if ( apply_filters( 'give_customer_recount_sholud_increase_value', true, $payment ) ) {
89
-						$payment_amount = give_get_payment_amount( $payment->ID );
88
+					if (apply_filters('give_customer_recount_sholud_increase_value', true, $payment)) {
89
+						$payment_amount = give_get_payment_amount($payment->ID);
90 90
 						$step_total += $payment_amount;
91 91
 					}
92 92
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 			}
96 96
 
97 97
 			$updated_total = $pending_total + $step_total;
98
-			$this->store_data( 'give_stats_customer_pending_total' . $customer->id, $updated_total );
99
-			$this->store_data( 'give_stats_found_payments_' . $customer->id, $found_payment_ids );
98
+			$this->store_data('give_stats_customer_pending_total'.$customer->id, $updated_total);
99
+			$this->store_data('give_stats_found_payments_'.$customer->id, $found_payment_ids);
100 100
 
101 101
 			return true;
102 102
 		}
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function get_percentage_complete() {
115 115
 
116
-		$payments = $this->get_stored_data( 'give_recount_customer_payments_' . $this->customer_id );
117
-		$total    = count( $payments );
116
+		$payments = $this->get_stored_data('give_recount_customer_payments_'.$this->customer_id);
117
+		$total    = count($payments);
118 118
 
119 119
 		$percentage = 100;
120 120
 
121
-		if ( $total > 0 ) {
122
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
121
+		if ($total > 0) {
122
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
123 123
 		}
124 124
 
125
-		if ( $percentage > 100 ) {
125
+		if ($percentage > 100) {
126 126
 			$percentage = 100;
127 127
 		}
128 128
 
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @param array $request The Form Data passed into the batch processing
138 138
 	 */
139
-	public function set_properties( $request ) {
140
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
139
+	public function set_properties($request) {
140
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
141 141
 	}
142 142
 
143 143
 	/**
@@ -148,62 +148,62 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function process_step() {
150 150
 
151
-		if ( ! $this->can_export() ) {
152
-			wp_die( __( 'You do not have permission to recount stats.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
151
+		if ( ! $this->can_export()) {
152
+			wp_die(__('You do not have permission to recount stats.', 'give'), __('Error', 'give'), array('response' => 403));
153 153
 		}
154 154
 
155 155
 		$had_data = $this->get_data();
156 156
 
157
-		if ( $had_data ) {
157
+		if ($had_data) {
158 158
 			$this->done = false;
159 159
 
160 160
 			return true;
161 161
 		} else {
162
-			$customer    = new Give_Customer( $this->customer_id );
163
-			$payment_ids = get_option( 'give_stats_found_payments_' . $customer->id, array() );
164
-			$this->delete_data( 'give_stats_found_payments_' . $customer->id );
162
+			$customer    = new Give_Customer($this->customer_id);
163
+			$payment_ids = get_option('give_stats_found_payments_'.$customer->id, array());
164
+			$this->delete_data('give_stats_found_payments_'.$customer->id);
165 165
 
166
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $customer->id, array() ) );
166
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$customer->id, array()));
167 167
 
168 168
 			// Find non-existing payments (deleted) and total up the purchase count
169 169
 			$purchase_count = 0;
170
-			foreach ( $payment_ids as $key => $payment_id ) {
171
-				if ( in_array( $payment_id, $removed_payments ) ) {
172
-					unset( $payment_ids[ $key ] );
170
+			foreach ($payment_ids as $key => $payment_id) {
171
+				if (in_array($payment_id, $removed_payments)) {
172
+					unset($payment_ids[$key]);
173 173
 					continue;
174 174
 				}
175 175
 
176
-				$payment = get_post( $payment_id );
177
-				if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) {
178
-					$purchase_count ++;
176
+				$payment = get_post($payment_id);
177
+				if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) {
178
+					$purchase_count++;
179 179
 				}
180 180
 			}
181 181
 
182
-			$this->delete_data( 'give_stats_missing_payments' . $customer->id );
182
+			$this->delete_data('give_stats_missing_payments'.$customer->id);
183 183
 
184
-			$pending_total = $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 );
185
-			$this->delete_data( 'give_stats_customer_pending_total' . $customer->id );
186
-			$this->delete_data( 'give_recount_customer_stats_' . $customer->id );
187
-			$this->delete_data( 'give_recount_customer_payments_' . $this->customer_id );
184
+			$pending_total = $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0);
185
+			$this->delete_data('give_stats_customer_pending_total'.$customer->id);
186
+			$this->delete_data('give_recount_customer_stats_'.$customer->id);
187
+			$this->delete_data('give_recount_customer_payments_'.$this->customer_id);
188 188
 
189
-			$payment_ids = implode( ',', $payment_ids );
190
-			$customer->update( array( 'payment_ids'    => $payment_ids,
189
+			$payment_ids = implode(',', $payment_ids);
190
+			$customer->update(array('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 = __( 'Donor stats successfully recounted.', 'give' );
196
+			$this->message = __('Donor stats 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_customer_payment_statuses', give_get_payment_status_keys() );
233
+		if ($this->step === 1) {
234
+			$allowed_payment_status = apply_filters('give_recount_customer_payment_statuses', give_get_payment_status_keys());
235 235
 
236 236
 			// Before we start, let's zero out the customer's data
237
-			$customer = new Give_Customer( $this->customer_id );
238
-			$customer->update( array( 'purchase_value' => give_format_amount( 0 ), 'purchase_count' => 0 ) );
237
+			$customer = new Give_Customer($this->customer_id);
238
+			$customer->update(array('purchase_value' => give_format_amount(0), 'purchase_count' => 0));
239 239
 
240
-			$attached_payment_ids = explode( ',', $customer->payment_ids );
240
+			$attached_payment_ids = explode(',', $customer->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_post_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_post_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_customer_payments_' . $customer->id, $payments );
266
+			$this->store_data('give_recount_customer_payments_'.$customer->id, $payments);
267 267
 		}
268 268
 	}
269 269
 
@@ -276,11 +276,11 @@  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
-		return empty( $value ) ? false : maybe_unserialize( $value );
283
+		return empty($value) ? false : maybe_unserialize($value);
284 284
 	}
285 285
 
286 286
 	/**
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return void
295 295
 	 */
296
-	private function store_data( $key, $value ) {
296
+	private function store_data($key, $value) {
297 297
 		global $wpdb;
298 298
 
299
-		$value = maybe_serialize( $value );
299
+		$value = maybe_serialize($value);
300 300
 
301 301
 		$data = array(
302 302
 			'option_name'  => $key,
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			'%s',
311 311
 		);
312 312
 
313
-		$wpdb->replace( $wpdb->options, $data, $formats );
313
+		$wpdb->replace($wpdb->options, $data, $formats);
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @return void
324 324
 	 */
325
-	private function delete_data( $key ) {
325
+	private function delete_data($key) {
326 326
 		global $wpdb;
327
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
327
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
328 328
 	}
329 329
 
330 330
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php 2 patches
Spacing   +37 added lines, -37 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
 
@@ -56,32 +56,32 @@  discard block
 block discarded – undo
56 56
 
57 57
 		$args = array(
58 58
 			'number'  => $this->per_step,
59
-			'offset'  => $this->per_step * ( $this->step - 1 ),
59
+			'offset'  => $this->per_step * ($this->step - 1),
60 60
 			'orderby' => 'id',
61 61
 			'order'   => 'DESC',
62 62
 		);
63 63
 
64
-		$customers = Give()->customers->get_customers( $args );
64
+		$customers = Give()->customers->get_customers($args);
65 65
 
66
-		if ( $customers ) {
66
+		if ($customers) {
67 67
 
68
-			$allowed_payment_status = apply_filters( 'give_recount_customer_payment_statuses', give_get_payment_status_keys() );
68
+			$allowed_payment_status = apply_filters('give_recount_customer_payment_statuses', give_get_payment_status_keys());
69 69
 
70
-			foreach ( $customers as $customer ) {
70
+			foreach ($customers as $customer) {
71 71
 
72
-				$attached_payment_ids = explode( ',', $customer->payment_ids );
72
+				$attached_payment_ids = explode(',', $customer->payment_ids);
73 73
 
74 74
 				$attached_args = array(
75 75
 					'post__in' => $attached_payment_ids,
76
-					'number'   => - 1,
76
+					'number'   => -1,
77 77
 					'status'   => $allowed_payment_status,
78 78
 				);
79 79
 
80
-				$attached_payments = (array) give_get_payments( $attached_args );
80
+				$attached_payments = (array) give_get_payments($attached_args);
81 81
 
82 82
 				$unattached_args = array(
83 83
 					'post__not_in' => $attached_payment_ids,
84
-					'number'       => - 1,
84
+					'number'       => -1,
85 85
 					'status'       => $allowed_payment_status,
86 86
 					'meta_query'   => array(
87 87
 						array(
@@ -92,29 +92,29 @@  discard block
 block discarded – undo
92 92
 					),
93 93
 				);
94 94
 
95
-				$unattached_payments = give_get_payments( $unattached_args );
95
+				$unattached_payments = give_get_payments($unattached_args);
96 96
 
97
-				$payments = array_merge( $attached_payments, $unattached_payments );
97
+				$payments = array_merge($attached_payments, $unattached_payments);
98 98
 
99 99
 				$purchase_value = 0.00;
100 100
 				$purchase_count = 0;
101 101
 				$payment_ids    = array();
102 102
 
103
-				if ( $payments ) {
103
+				if ($payments) {
104 104
 
105
-					foreach ( $payments as $payment ) {
105
+					foreach ($payments as $payment) {
106 106
 
107 107
 						$should_process_payment = 'publish' == $payment->post_status || 'revoked' == $payment->post_status ? true : false;
108
-						$should_process_payment = apply_filters( 'give_customer_recount_should_process_payment', $should_process_payment, $payment );
108
+						$should_process_payment = apply_filters('give_customer_recount_should_process_payment', $should_process_payment, $payment);
109 109
 
110
-						if ( true === $should_process_payment ) {
110
+						if (true === $should_process_payment) {
111 111
 
112
-							if ( apply_filters( 'give_customer_recount_should_increase_value', true, $payment ) ) {
113
-								$purchase_value += give_get_payment_amount( $payment->ID );
112
+							if (apply_filters('give_customer_recount_should_increase_value', true, $payment)) {
113
+								$purchase_value += give_get_payment_amount($payment->ID);
114 114
 							}
115 115
 
116
-							if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) {
117
-								$purchase_count ++;
116
+							if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) {
117
+								$purchase_count++;
118 118
 							}
119 119
 
120 120
 						}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
 				}
126 126
 
127
-				$payment_ids = implode( ',', $payment_ids );
127
+				$payment_ids = implode(',', $payment_ids);
128 128
 
129 129
 				$customer_update_data = array(
130 130
 					'purchase_count' => $purchase_count,
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 					'payment_ids'    => $payment_ids,
133 133
 				);
134 134
 
135
-				$customer_instance = new Give_Customer( $customer->id );
136
-				$customer_instance->update( $customer_update_data );
135
+				$customer_instance = new Give_Customer($customer->id);
136
+				$customer_instance->update($customer_update_data);
137 137
 
138 138
 			}
139 139
 
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
 	public function get_percentage_complete() {
154 154
 
155 155
 		$args = array(
156
-			'number'  => - 1,
156
+			'number'  => -1,
157 157
 			'orderby' => 'id',
158 158
 			'order'   => 'DESC',
159 159
 		);
160 160
 
161
-		$customers = Give()->customers->get_customers( $args );
162
-		$total     = count( $customers );
161
+		$customers = Give()->customers->get_customers($args);
162
+		$total     = count($customers);
163 163
 
164 164
 		$percentage = 100;
165 165
 
166
-		if ( $total > 0 ) {
167
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
166
+		if ($total > 0) {
167
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
168 168
 		}
169 169
 
170
-		if ( $percentage > 100 ) {
170
+		if ($percentage > 100) {
171 171
 			$percentage = 100;
172 172
 		}
173 173
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @param array $request The Form Data passed into the batch processing
183 183
 	 */
184
-	public function set_properties( $request ) {
184
+	public function set_properties($request) {
185 185
 	}
186 186
 
187 187
 	/**
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	public function process_step() {
194 194
 
195
-		if ( ! $this->can_export() ) {
196
-			wp_die( __( 'You do not have permission to export data.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
195
+		if ( ! $this->can_export()) {
196
+			wp_die(__('You do not have permission to export data.', 'give'), __('Error', 'give'), array('response' => 403));
197 197
 		}
198 198
 
199 199
 		$had_data = $this->get_data();
200 200
 
201
-		if ( $had_data ) {
201
+		if ($had_data) {
202 202
 			$this->done = false;
203 203
 
204 204
 			return true;
205 205
 		} else {
206 206
 			$this->done    = true;
207
-			$this->message = __( 'Donor stats successfully recounted.', 'give' );
207
+			$this->message = __('Donor stats successfully recounted.', 'give');
208 208
 
209 209
 			return false;
210 210
 		}
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
 	 * Headers
215 215
 	 */
216 216
 	public function headers() {
217
-		ignore_user_abort( true );
217
+		ignore_user_abort(true);
218 218
 
219
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
220
-			set_time_limit( 0 );
219
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
220
+			set_time_limit(0);
221 221
 		}
222 222
 	}
223 223
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
includes/admin/reporting/tools/tools-actions.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
  * @since  1.5
20 20
  */
21 21
 function give_register_batch_recount_store_earnings_tool() {
22
-	add_action( 'give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1 );
22
+	add_action('give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1);
23 23
 }
24 24
 
25
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10 );
25
+add_action('give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10);
26 26
 
27 27
 /**
28 28
  * Loads the tools batch processing class for recounting store earnings
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
  *
34 34
  * @return void
35 35
  */
36
-function give_include_recount_income_tool_batch_processor( $class ) {
36
+function give_include_recount_income_tool_batch_processor($class) {
37 37
 
38
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-income.php';
38
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-income.php';
39 39
 
40
-	if ( 'Give_Tools_Recount_Income' === $class && file_exists( $file_path ) ) {
40
+	if ('Give_Tools_Recount_Income' === $class && file_exists($file_path)) {
41 41
 		require_once $file_path;
42 42
 	}
43 43
 
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
  * @since  1.5
50 50
  */
51 51
 function give_register_batch_recount_form_tool() {
52
-	add_action( 'give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1 );
52
+	add_action('give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1);
53 53
 }
54 54
 
55
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10 );
55
+add_action('give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10);
56 56
 
57 57
 /**
58 58
  * Loads the tools batch processing class for recounting download stats
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
  *
64 64
  * @return void
65 65
  */
66
-function give_include_recount_form_tool_batch_processor( $class ) {
66
+function give_include_recount_form_tool_batch_processor($class) {
67 67
 
68
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php';
68
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php';
69 69
 
70
-	if ( 'Give_Tools_Recount_Form_Stats' === $class && file_exists( $file_path ) ) {
70
+	if ('Give_Tools_Recount_Form_Stats' === $class && file_exists($file_path)) {
71 71
 		require_once $file_path;
72 72
 	}
73 73
 
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
  * @since  1.5
79 79
  */
80 80
 function give_register_batch_recount_all_tool() {
81
-	add_action( 'give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1 );
81
+	add_action('give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1);
82 82
 }
83 83
 
84
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10 );
84
+add_action('give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10);
85 85
 
86 86
 /**
87 87
  * Loads the tools batch processing class for recounting all stats
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return void
94 94
  */
95
-function give_include_recount_all_tool_batch_processor( $class ) {
96
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php';
97
-	if ( 'Give_Tools_Recount_All_Stats' === $class && file_exists( $file_path ) ) {
95
+function give_include_recount_all_tool_batch_processor($class) {
96
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php';
97
+	if ('Give_Tools_Recount_All_Stats' === $class && file_exists($file_path)) {
98 98
 		require_once $file_path;
99 99
 	}
100 100
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
  * @since  1.5
107 107
  */
108 108
 function give_register_batch_reset_tool() {
109
-	add_action( 'give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1 );
109
+	add_action('give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1);
110 110
 }
111 111
 
112
-add_action( 'give_register_batch_exporter', 'give_register_batch_reset_tool', 10 );
112
+add_action('give_register_batch_exporter', 'give_register_batch_reset_tool', 10);
113 113
 
114 114
 /**
115 115
  * Loads the tools batch processing class for resetting store and product earnings
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return void
122 122
  */
123
-function give_include_reset_tool_batch_processor( $class ) {
123
+function give_include_reset_tool_batch_processor($class) {
124 124
 
125
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-reset-stats.php';
125
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-reset-stats.php';
126 126
 
127
-	if ( 'Give_Tools_Reset_Stats' === $class && file_exists( $file_path ) ) {
127
+	if ('Give_Tools_Reset_Stats' === $class && file_exists($file_path)) {
128 128
 		require_once $file_path;
129 129
 	}
130 130
 
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
  * @since  1.5
136 136
  */
137 137
 function give_register_batch_customer_recount_tool() {
138
-	add_action( 'give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1 );
138
+	add_action('give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1);
139 139
 }
140 140
 
141
-add_action( 'give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10 );
141
+add_action('give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10);
142 142
 
143 143
 /**
144 144
  * Loads the tools batch processing class for resetting all customer stats
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
  *
150 150
  * @return void
151 151
  */
152
-function give_include_customer_recount_tool_batch_processor( $class ) {
152
+function give_include_customer_recount_tool_batch_processor($class) {
153 153
 
154
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php';
154
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php';
155 155
 
156
-	if ( 'Give_Tools_Recount_Customer_Stats' === $class && file_exists( $file_path ) ) {
156
+	if ('Give_Tools_Recount_Customer_Stats' === $class && file_exists($file_path)) {
157 157
 		require_once $file_path;
158 158
 	}
159 159
 
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
  * @since  1.5
165 165
  */
166 166
 function give_register_batch_delete_test_transactions_tool() {
167
-	add_action( 'give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1 );
167
+	add_action('give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1);
168 168
 }
169 169
 
170
-add_action( 'give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10 );
170
+add_action('give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10);
171 171
 
172 172
 /**
173 173
  * Loads the tools batch processing class for resetting all customer stats
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
  *
179 179
  * @return void
180 180
  */
181
-function give_include_delete_test_transactions_batch_processor( $class ) {
181
+function give_include_delete_test_transactions_batch_processor($class) {
182 182
 
183
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php';
183
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php';
184 184
 
185
-	if ( 'Give_Tools_Delete_Test_Transactions' === $class && file_exists( $file_path ) ) {
185
+	if ('Give_Tools_Delete_Test_Transactions' === $class && file_exists($file_path)) {
186 186
 		require_once $file_path;
187 187
 	}
188 188
 
Please login to merge, or discard this patch.
includes/admin/reporting/class-form-reports-table.php 1 patch
Spacing   +55 added lines, -55 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
 /**
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 		global $status, $page;
51 51
 
52 52
 		// Set parent defaults
53
-		parent::__construct( array(
54
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
55
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
53
+		parent::__construct(array(
54
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
55
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
56 56
 			'ajax'     => false                        // Does this table support ajax?
57
-		) );
57
+		));
58 58
 
59
-		add_action( 'give_report_view_actions', array( $this, 'category_filter' ) );
59
+		add_action('give_report_view_actions', array($this, 'category_filter'));
60 60
 		$this->query();
61 61
 
62 62
 	}
@@ -72,18 +72,18 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return string Column Name
74 74
 	 */
75
-	public function column_default( $item, $column_name ) {
76
-		switch ( $column_name ) {
75
+	public function column_default($item, $column_name) {
76
+		switch ($column_name) {
77 77
 			case 'earnings' :
78
-				return give_currency_filter( give_format_amount( $item[ $column_name ] ) );
78
+				return give_currency_filter(give_format_amount($item[$column_name]));
79 79
 			case 'average_sales' :
80
-				return round( $item[ $column_name ] );
80
+				return round($item[$column_name]);
81 81
 			case 'average_earnings' :
82
-				return give_currency_filter( give_format_amount( $item[ $column_name ] ) );
82
+				return give_currency_filter(give_format_amount($item[$column_name]));
83 83
 			case 'details' :
84
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $item['ID'] ) . '">' . __( 'View Detailed Report', 'give' ) . '</a>';
84
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$item['ID']).'">'.__('View Detailed Report', 'give').'</a>';
85 85
 			default:
86
-				return $item[ $column_name ];
86
+				return $item[$column_name];
87 87
 		}
88 88
 	}
89 89
 
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	public function get_columns() {
98 98
 		$columns = array(
99 99
 			'title'            => give_get_forms_label_singular(),
100
-			'sales'            => __( 'Donations', 'give' ),
101
-			'earnings'         => __( 'Income', 'give' ),
102
-			'average_sales'    => __( 'Monthly Average Donations', 'give' ),
103
-			'average_earnings' => __( 'Monthly Average Income', 'give' ),
104
-			'details'          => __( 'Detailed Report', 'give' )
100
+			'sales'            => __('Donations', 'give'),
101
+			'earnings'         => __('Income', 'give'),
102
+			'average_sales'    => __('Monthly Average Donations', 'give'),
103
+			'average_earnings' => __('Monthly Average Income', 'give'),
104
+			'details'          => __('Detailed Report', 'give')
105 105
 		);
106 106
 
107 107
 		return $columns;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function get_sortable_columns() {
118 118
 		return array(
119
-			'title'    => array( 'title', true ),
120
-			'sales'    => array( 'sales', false ),
121
-			'earnings' => array( 'earnings', false ),
119
+			'title'    => array('title', true),
120
+			'sales'    => array('sales', false),
121
+			'earnings' => array('earnings', false),
122 122
 		);
123 123
 	}
124 124
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @return int Current page number
131 131
 	 */
132 132
 	public function get_paged() {
133
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
133
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
134 134
 	}
135 135
 
136 136
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @return int Category ID
143 143
 	 */
144 144
 	public function get_category() {
145
-		return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0;
145
+		return isset($_GET['category']) ? absint($_GET['category']) : 0;
146 146
 	}
147 147
 
148 148
 
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function get_total_forms() {
157 157
 		$total  = 0;
158
-		$counts = wp_count_posts( 'give_forms', 'readable' );
159
-		foreach ( $counts as $status => $count ) {
158
+		$counts = wp_count_posts('give_forms', 'readable');
159
+		foreach ($counts as $status => $count) {
160 160
 			$total += $count;
161 161
 		}
162 162
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 * @since  1.0
171 171
 	 * @return void
172 172
 	 */
173
-	public function bulk_actions( $which = '' ) {
173
+	public function bulk_actions($which = '') {
174 174
 		// These aren't really bulk actions but this outputs the markup in the right place
175 175
 		give_report_views();
176 176
 	}
@@ -183,23 +183,23 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param string $which
185 185
 	 */
186
-	protected function display_tablenav( $which ) {
186
+	protected function display_tablenav($which) {
187 187
 
188
-		if ( 'top' == $which ) {
189
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
188
+		if ('top' == $which) {
189
+			wp_nonce_field('bulk-'.$this->_args['plural']);
190 190
 		}
191 191
 		?>
192
-		<div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
192
+		<div class="tablenav give-clearfix <?php echo esc_attr($which); ?>">
193 193
 
194
-			<h3 class="alignleft reports-earnings-title"><span><?php _e( 'Donation Forms Report', 'give' ); ?></span></h3>
194
+			<h3 class="alignleft reports-earnings-title"><span><?php _e('Donation Forms Report', 'give'); ?></span></h3>
195 195
 
196 196
 			<div class="alignright tablenav-right">
197 197
 				<div class="actions bulkactions">
198
-					<?php $this->bulk_actions( $which ); ?>
198
+					<?php $this->bulk_actions($which); ?>
199 199
 				</div>
200 200
 				<?php
201
-				$this->extra_tablenav( $which );
202
-				$this->pagination( $which );
201
+				$this->extra_tablenav($which);
202
+				$this->pagination($which);
203 203
 				?>
204 204
 			</div>
205 205
 
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function category_filter() {
221 221
 
222
-		$categories = get_terms( 'form_category' );
223
-		if ( $categories && ! is_wp_error( $categories ) ) {
224
-			echo Give()->html->category_dropdown( 'category', $this->get_category() );
222
+		$categories = get_terms('form_category');
223
+		if ($categories && ! is_wp_error($categories)) {
224
+			echo Give()->html->category_dropdown('category', $this->get_category());
225 225
 		}
226 226
 	}
227 227
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	 */
236 236
 	public function query() {
237 237
 
238
-		$orderby  = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title';
239
-		$order    = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
238
+		$orderby  = isset($_GET['orderby']) ? $_GET['orderby'] : 'title';
239
+		$order    = isset($_GET['order']) ? $_GET['order'] : 'DESC';
240 240
 		$category = $this->get_category();
241 241
 
242 242
 		$args = array(
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 			'suppress_filters' => true
250 250
 		);
251 251
 
252
-		if ( ! empty( $category ) ) {
252
+		if ( ! empty($category)) {
253 253
 			$args['tax_query'] = array(
254 254
 				array(
255 255
 					'taxonomy' => 'form_category',
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			);
259 259
 		}
260 260
 
261
-		switch ( $orderby ) :
261
+		switch ($orderby) :
262 262
 			case 'title' :
263 263
 				$args['orderby'] = 'title';
264 264
 				break;
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 				break;
275 275
 		endswitch;
276 276
 
277
-		$args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this );
277
+		$args = apply_filters('give_form_reports_prepare_items_args', $args, $this);
278 278
 
279
-		$this->products = new WP_Query( $args );
279
+		$this->products = new WP_Query($args);
280 280
 
281 281
 	}
282 282
 
@@ -292,15 +292,15 @@  discard block
 block discarded – undo
292 292
 
293 293
 		$give_forms = $this->products->posts;
294 294
 
295
-		if ( $give_forms ) {
296
-			foreach ( $give_forms as $form ) {
295
+		if ($give_forms) {
296
+			foreach ($give_forms as $form) {
297 297
 				$reports_data[] = array(
298 298
 					'ID'               => $form,
299
-					'title'            => get_the_title( $form ),
300
-					'sales'            => give_get_form_sales_stats( $form ),
301
-					'earnings'         => give_get_form_earnings_stats( $form ),
302
-					'average_sales'    => give_get_average_monthly_form_sales( $form ),
303
-					'average_earnings' => give_get_average_monthly_form_earnings( $form )
299
+					'title'            => get_the_title($form),
300
+					'sales'            => give_get_form_sales_stats($form),
301
+					'earnings'         => give_get_form_earnings_stats($form),
302
+					'average_sales'    => give_get_average_monthly_form_sales($form),
303
+					'average_earnings' => give_get_average_monthly_form_earnings($form)
304 304
 				);
305 305
 			}
306 306
 		}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 
329 329
 		$sortable = $this->get_sortable_columns();
330 330
 
331
-		$this->_column_headers = array( $columns, $hidden, $sortable );
331
+		$this->_column_headers = array($columns, $hidden, $sortable);
332 332
 
333 333
 		$data = $this->reports_data();
334 334
 
@@ -336,10 +336,10 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$this->items = $data;
338 338
 
339
-		$this->set_pagination_args( array(
339
+		$this->set_pagination_args(array(
340 340
 				'total_items' => $total_items,
341 341
 				'per_page'    => $this->per_page,
342
-				'total_pages' => ceil( $total_items / $this->per_page )
342
+				'total_pages' => ceil($total_items / $this->per_page)
343 343
 			)
344 344
 		);
345 345
 	}
Please login to merge, or discard this patch.
includes/class-give-db.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.0
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 } // Exit if accessed directly
15 15
 
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 	 * @since   1.0
81 81
 	 * @return  object
82 82
 	 */
83
-	public function get( $row_id ) {
83
+	public function get($row_id) {
84 84
 		global $wpdb;
85 85
 
86
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
86
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
87 87
 	}
88 88
 
89 89
 	/**
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 	 * @since   1.0
94 94
 	 * @return  object
95 95
 	 */
96
-	public function get_by( $column, $row_id ) {
96
+	public function get_by($column, $row_id) {
97 97
 		global $wpdb;
98
-		$column = esc_sql( $column );
99
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
98
+		$column = esc_sql($column);
99
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 	 * @since   1.0
107 107
 	 * @return  string
108 108
 	 */
109
-	public function get_column( $column, $row_id ) {
109
+	public function get_column($column, $row_id) {
110 110
 		global $wpdb;
111
-		$column = esc_sql( $column );
112
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
111
+		$column = esc_sql($column);
112
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
113 113
 	}
114 114
 
115 115
 	/**
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	 * @since   1.0
120 120
 	 * @return  string
121 121
 	 */
122
-	public function get_column_by( $column, $column_where, $column_value ) {
122
+	public function get_column_by($column, $column_where, $column_value) {
123 123
 		global $wpdb;
124
-		$column_where = esc_sql( $column_where );
125
-		$column       = esc_sql( $column );
126
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
124
+		$column_where = esc_sql($column_where);
125
+		$column       = esc_sql($column);
126
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
127 127
 	}
128 128
 
129 129
 	/**
@@ -133,30 +133,30 @@  discard block
 block discarded – undo
133 133
 	 * @since   1.0
134 134
 	 * @return  int
135 135
 	 */
136
-	public function insert( $data, $type = '' ) {
136
+	public function insert($data, $type = '') {
137 137
 		global $wpdb;
138 138
 
139 139
 		// Set default values
140
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
140
+		$data = wp_parse_args($data, $this->get_column_defaults());
141 141
 
142
-		do_action( 'give_pre_insert_' . $type, $data );
142
+		do_action('give_pre_insert_'.$type, $data);
143 143
 
144 144
 		// Initialise column format array
145 145
 		$column_formats = $this->get_columns();
146 146
 
147 147
 		// Force fields to lower case
148
-		$data = array_change_key_case( $data );
148
+		$data = array_change_key_case($data);
149 149
 
150 150
 		// White list columns
151
-		$data = array_intersect_key( $data, $column_formats );
151
+		$data = array_intersect_key($data, $column_formats);
152 152
 
153 153
 		// Reorder $column_formats to match the order of columns given in $data
154
-		$data_keys      = array_keys( $data );
155
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
154
+		$data_keys      = array_keys($data);
155
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
156 156
 
157
-		$wpdb->insert( $this->table_name, $data, $column_formats );
157
+		$wpdb->insert($this->table_name, $data, $column_formats);
158 158
 
159
-		do_action( 'give_post_insert_' . $type, $wpdb->insert_id, $data );
159
+		do_action('give_post_insert_'.$type, $wpdb->insert_id, $data);
160 160
 
161 161
 		return $wpdb->insert_id;
162 162
 	}
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
 	 * @since   1.0
169 169
 	 * @return  bool
170 170
 	 */
171
-	public function update( $row_id, $data = array(), $where = '' ) {
171
+	public function update($row_id, $data = array(), $where = '') {
172 172
 
173 173
 		global $wpdb;
174 174
 
175 175
 		// Row ID must be positive integer
176
-		$row_id = absint( $row_id );
176
+		$row_id = absint($row_id);
177 177
 
178
-		if ( empty( $row_id ) ) {
178
+		if (empty($row_id)) {
179 179
 			return false;
180 180
 		}
181 181
 
182
-		if ( empty( $where ) ) {
182
+		if (empty($where)) {
183 183
 			$where = $this->primary_key;
184 184
 		}
185 185
 
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
 		$column_formats = $this->get_columns();
188 188
 
189 189
 		// Force fields to lower case
190
-		$data = array_change_key_case( $data );
190
+		$data = array_change_key_case($data);
191 191
 
192 192
 		// White list columns
193
-		$data = array_intersect_key( $data, $column_formats );
193
+		$data = array_intersect_key($data, $column_formats);
194 194
 
195 195
 		// Reorder $column_formats to match the order of columns given in $data
196
-		$data_keys      = array_keys( $data );
197
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
196
+		$data_keys      = array_keys($data);
197
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
198 198
 
199
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
199
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
200 200
 			return false;
201 201
 		}
202 202
 
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
 	 * @since   1.0
211 211
 	 * @return  bool
212 212
 	 */
213
-	public function delete( $row_id = 0 ) {
213
+	public function delete($row_id = 0) {
214 214
 
215 215
 		global $wpdb;
216 216
 
217 217
 		// Row ID must be positive integer
218
-		$row_id = absint( $row_id );
218
+		$row_id = absint($row_id);
219 219
 
220
-		if ( empty( $row_id ) ) {
220
+		if (empty($row_id)) {
221 221
 			return false;
222 222
 		}
223 223
 
224
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
224
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
225 225
 			return false;
226 226
 		}
227 227
 
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 	 * @param  string $table The table name
236 236
 	 * @return bool          If the table name exists
237 237
 	 */
238
-	public function table_exists( $table ) {
238
+	public function table_exists($table) {
239 239
 		global $wpdb;
240
-		$table = sanitize_text_field( $table );
240
+		$table = sanitize_text_field($table);
241 241
 
242
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
242
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
243 243
 	}
244 244
 
245 245
 }
246 246
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-gravatars.php 1 patch
Spacing   +96 added lines, -96 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
 
@@ -50,50 +50,50 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 
52 52
 	// https://gist.github.com/justinph/5197810
53
-	function validate_gravatar( $id_or_email ) {
53
+	function validate_gravatar($id_or_email) {
54 54
 		//id or email code borrowed from wp-includes/pluggable.php
55 55
 		$email = '';
56
-		if ( is_numeric( $id_or_email ) ) {
56
+		if (is_numeric($id_or_email)) {
57 57
 			$id   = (int) $id_or_email;
58
-			$user = get_userdata( $id );
59
-			if ( $user ) {
58
+			$user = get_userdata($id);
59
+			if ($user) {
60 60
 				$email = $user->user_email;
61 61
 			}
62
-		} elseif ( is_object( $id_or_email ) ) {
62
+		} elseif (is_object($id_or_email)) {
63 63
 			// No avatar for pingbacks or trackbacks
64
-			$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
65
-			if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
64
+			$allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
65
+			if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) {
66 66
 				return false;
67 67
 			}
68 68
 
69
-			if ( ! empty( $id_or_email->user_id ) ) {
69
+			if ( ! empty($id_or_email->user_id)) {
70 70
 				$id   = (int) $id_or_email->user_id;
71
-				$user = get_userdata( $id );
72
-				if ( $user ) {
71
+				$user = get_userdata($id);
72
+				if ($user) {
73 73
 					$email = $user->user_email;
74 74
 				}
75
-			} elseif ( ! empty( $id_or_email->comment_author_email ) ) {
75
+			} elseif ( ! empty($id_or_email->comment_author_email)) {
76 76
 				$email = $id_or_email->comment_author_email;
77 77
 			}
78 78
 		} else {
79 79
 			$email = $id_or_email;
80 80
 		}
81 81
 
82
-		$hashkey = md5( strtolower( trim( $email ) ) );
83
-		$uri     = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404';
82
+		$hashkey = md5(strtolower(trim($email)));
83
+		$uri     = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404';
84 84
 
85
-		$data = wp_cache_get( $hashkey );
86
-		if ( false === $data ) {
87
-			$response = wp_remote_head( $uri );
88
-			if ( is_wp_error( $response ) ) {
85
+		$data = wp_cache_get($hashkey);
86
+		if (false === $data) {
87
+			$response = wp_remote_head($uri);
88
+			if (is_wp_error($response)) {
89 89
 				$data = 'not200';
90 90
 			} else {
91 91
 				$data = $response['response']['code'];
92 92
 			}
93
-			wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 );
93
+			wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5);
94 94
 
95 95
 		}
96
-		if ( $data == '200' ) {
96
+		if ($data == '200') {
97 97
 			return true;
98 98
 		} else {
99 99
 			return false;
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param int $form_id
110 110
 	 */
111
-	function get_log_ids( $form_id = '' ) {
111
+	function get_log_ids($form_id = '') {
112 112
 
113 113
 		// get Give_Logging class
114 114
 		global $give_logs;
115 115
 
116 116
 		// get log for this form
117
-		$logs = $give_logs->get_logs( $form_id );
117
+		$logs = $give_logs->get_logs($form_id);
118 118
 
119
-		if ( $logs ) {
119
+		if ($logs) {
120 120
 			// make an array with all the donor IDs
121
-			foreach ( $logs as $log ) {
121
+			foreach ($logs as $log) {
122 122
 				$log_ids[] = $log->ID;
123 123
 			}
124 124
 
@@ -135,49 +135,49 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @since 1.0
137 137
 	 */
138
-	function get_payment_ids( $form_id = '' ) {
138
+	function get_payment_ids($form_id = '') {
139 139
 
140 140
 		global $give_options;
141 141
 
142
-		$log_ids = $this->get_log_ids( $form_id );
142
+		$log_ids = $this->get_log_ids($form_id);
143 143
 
144
-		if ( $log_ids ) {
144
+		if ($log_ids) {
145 145
 
146 146
 			$payment_ids = array();
147 147
 
148
-			foreach ( $log_ids as $id ) {
148
+			foreach ($log_ids as $id) {
149 149
 				// get the payment ID for each corresponding log ID
150
-				$payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true );
150
+				$payment_ids[] = get_post_meta($id, '_give_log_payment_id', true);
151 151
 			}
152 152
 
153 153
 			// remove donors who have purchased more than once so we can have unique avatars
154 154
 			$unique_emails = array();
155 155
 
156
-			foreach ( $payment_ids as $key => $id ) {
156
+			foreach ($payment_ids as $key => $id) {
157 157
 
158
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
158
+				$email = get_post_meta($id, '_give_payment_user_email', true);
159 159
 
160
-				if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) {
161
-					if ( ! $this->validate_gravatar( $email ) ) {
160
+				if (isset ($give_options['give_donators_gravatars_has_gravatar_account'])) {
161
+					if ( ! $this->validate_gravatar($email)) {
162 162
 						continue;
163 163
 					}
164 164
 				}
165 165
 
166
-				$unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true );
166
+				$unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true);
167 167
 
168 168
 			}
169 169
 
170 170
 			// strip duplicate emails
171
-			$unique_emails = array_unique( $unique_emails );
171
+			$unique_emails = array_unique($unique_emails);
172 172
 
173 173
 			// convert the unique IDs back into simple array
174
-			foreach ( $unique_emails as $id => $email ) {
174
+			foreach ($unique_emails as $id => $email) {
175 175
 				$unique_ids[] = $id;
176 176
 			}
177 177
 
178 178
 			// randomize the payment IDs if enabled
179
-			if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) {
180
-				shuffle( $unique_ids );
179
+			if (isset($give_options['give_donators_gravatars_random_gravatars'])) {
180
+				shuffle($unique_ids);
181 181
 			}
182 182
 
183 183
 			// return our unique IDs
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @since 1.0
195 195
 	 */
196
-	function gravatars( $form_id = false, $title = '' ) {
196
+	function gravatars($form_id = false, $title = '') {
197 197
 
198 198
 		// unique $payment_ids 
199
-		$payment_ids = $this->get_payment_ids( $form_id );
199
+		$payment_ids = $this->get_payment_ids($form_id);
200 200
 
201 201
 		//			var_dump( $payment_ids );
202 202
 		//			 var_dump( $this->get_log_ids( get_the_ID() ) );
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 		global $give_options;
205 205
 
206 206
 		// return if no ID
207
-		if ( ! $form_id ) {
207
+		if ( ! $form_id) {
208 208
 			return;
209 209
 		}
210 210
 
211 211
 		// minimum amount of purchases before showing gravatars
212 212
 		// if the number of items in array is not greater or equal to the number specified, then exit
213
-		if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) {
214
-			if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) {
213
+		if (isset($give_options['give_donators_gravatars_min_purchases_required']) && '' != $give_options['give_donators_gravatars_min_purchases_required']) {
214
+			if ( ! (count($payment_ids) >= $give_options['give_donators_gravatars_min_purchases_required'])) {
215 215
 				return;
216 216
 			}
217 217
 		}
@@ -222,51 +222,51 @@  discard block
 block discarded – undo
222 222
 		echo '<div id="give-purchase-gravatars">';
223 223
 
224 224
 
225
-		if ( isset ( $title ) ) {
225
+		if (isset ($title)) {
226 226
 
227
-			if ( $title ) {
228
-				echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' );
229
-			} elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) {
230
-				echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donators_gravatars_heading'] ) . '</h2>' );
227
+			if ($title) {
228
+				echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>');
229
+			} elseif (isset($give_options['give_donators_gravatars_heading'])) {
230
+				echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donators_gravatars_heading']).'</h2>');
231 231
 			}
232 232
 
233 233
 		}
234 234
 		echo '<ul class="give-purchase-gravatars-list">';
235 235
 		$i = 0;
236 236
 
237
-		if ( $payment_ids ) {
238
-			foreach ( $payment_ids as $id ) {
237
+		if ($payment_ids) {
238
+			foreach ($payment_ids as $id) {
239 239
 
240 240
 				// Give saves a blank option even when the control is turned off, hence the extra check
241
-				if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) {
241
+				if (isset($give_options['give_donators_gravatars_maximum_number']) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number']) {
242 242
 					continue;
243 243
 				}
244 244
 
245 245
 				// get the payment meta
246
-				$payment_meta = get_post_meta( $id, '_give_payment_meta', true );
246
+				$payment_meta = get_post_meta($id, '_give_payment_meta', true);
247 247
 
248 248
 				// unserialize the payment meta
249
-				$user_info = maybe_unserialize( $payment_meta['user_info'] );
249
+				$user_info = maybe_unserialize($payment_meta['user_info']);
250 250
 
251 251
 				// get donor's first name
252 252
 				$name = $user_info['first_name'];
253 253
 
254 254
 				// get donor's email
255
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
255
+				$email = get_post_meta($id, '_give_payment_user_email', true);
256 256
 
257 257
 				// set gravatar size and provide filter
258
-				$size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : '';
258
+				$size = isset($give_options['give_donators_gravatars_gravatar_size']) ? apply_filters('give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size']) : '';
259 259
 
260 260
 				// default image
261
-				$default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false );
261
+				$default_image = apply_filters('give_donators_gravatars_gravatar_default_image', false);
262 262
 
263 263
 				// assemble output
264 264
 				$output .= '<li>';
265 265
 
266
-				$output .= get_avatar( $email, $size, $default_image, $name );
266
+				$output .= get_avatar($email, $size, $default_image, $name);
267 267
 				$output .= '</li>';
268 268
 
269
-				$i ++;
269
+				$i++;
270 270
 
271 271
 			} // end foreach
272 272
 		}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		echo '</ul>';
276 276
 		echo '</div>';
277 277
 
278
-		return apply_filters( 'give_donators_gravatars', ob_get_clean() );
278
+		return apply_filters('give_donators_gravatars', ob_get_clean());
279 279
 	}
280 280
 
281 281
 	/**
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @since 1.0
285 285
 	 */
286 286
 	function register_widget() {
287
-		register_widget( 'Give_Donators_Gravatars_Widget' );
287
+		register_widget('Give_Donators_Gravatars_Widget');
288 288
 	}
289 289
 
290 290
 	/**
@@ -293,19 +293,19 @@  discard block
 block discarded – undo
293 293
 	 * @since 1.0
294 294
 	 * @todo  set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars
295 295
 	 */
296
-	function shortcode( $atts, $content = null ) {
296
+	function shortcode($atts, $content = null) {
297 297
 
298
-		$atts = shortcode_atts( array(
298
+		$atts = shortcode_atts(array(
299 299
 			'id'    => '',
300 300
 			'title' => ''
301
-		), $atts, 'give_donators_gravatars' );
301
+		), $atts, 'give_donators_gravatars');
302 302
 
303 303
 		// if no ID is passed on single give_forms pages, get the correct ID
304
-		if ( is_singular( 'give_forms' ) ) {
304
+		if (is_singular('give_forms')) {
305 305
 			$id = get_the_ID();
306 306
 		}
307 307
 
308
-		$content = $this->gravatars( $atts['id'], $atts['title'] );
308
+		$content = $this->gravatars($atts['id'], $atts['title']);
309 309
 
310 310
 		return $content;
311 311
 
@@ -316,56 +316,56 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @since 1.0
318 318
 	 */
319
-	function settings( $settings ) {
319
+	function settings($settings) {
320 320
 
321 321
 		$give_gravatar_settings = array(
322 322
 			array(
323
-				'name' => __( 'Donator Gravatars', 'give' ),
323
+				'name' => __('Donator Gravatars', 'give'),
324 324
 				'desc' => '<hr>',
325 325
 				'id'   => 'give_title',
326 326
 				'type' => 'give_title'
327 327
 			),
328 328
 			array(
329
-				'name' => __( 'Heading', 'give' ),
330
-				'desc' => __( 'The heading to display above the Gravatars', 'give' ),
329
+				'name' => __('Heading', 'give'),
330
+				'desc' => __('The heading to display above the Gravatars', 'give'),
331 331
 				'type' => 'text',
332 332
 				'id'   => 'give_donators_gravatars_heading'
333 333
 			),
334 334
 			array(
335
-				'name'    => __( 'Gravatar Size', 'give' ),
336
-				'desc'    => __( 'The size of each Gravatar in pixels (512px maximum)', 'give' ),
335
+				'name'    => __('Gravatar Size', 'give'),
336
+				'desc'    => __('The size of each Gravatar in pixels (512px maximum)', 'give'),
337 337
 				'type'    => 'text_small',
338 338
 				'id'      => 'give_donators_gravatars_gravatar_size',
339 339
 				'default' => '64'
340 340
 			),
341 341
 			array(
342
-				'name' => __( 'Minimum Unique Purchases Required', 'give' ),
343
-				'desc' => sprintf( __( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ),
342
+				'name' => __('Minimum Unique Purchases Required', 'give'),
343
+				'desc' => sprintf(__('The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), strtolower(give_get_forms_label_singular())),
344 344
 				'type' => 'text_small',
345 345
 				'id'   => 'give_donators_gravatars_min_purchases_required',
346 346
 			),
347 347
 			array(
348
-				'name'    => __( 'Maximum Gravatars To Show', 'give' ),
349
-				'desc'    => __( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ),
348
+				'name'    => __('Maximum Gravatars To Show', 'give'),
349
+				'desc'    => __('The maximum number of gravatars to show. Leave blank for no limit.', 'give'),
350 350
 				'type'    => 'text',
351 351
 				'id'      => 'give_donators_gravatars_maximum_number',
352 352
 				'default' => '20',
353 353
 			),
354 354
 			array(
355
-				'name' => __( 'Gravatar Visibility', 'give' ),
356
-				'desc' => __( 'Only show donators with a Gravatar account', 'give' ),
355
+				'name' => __('Gravatar Visibility', 'give'),
356
+				'desc' => __('Only show donators with a Gravatar account', 'give'),
357 357
 				'id'   => 'give_donators_gravatars_has_gravatar_account',
358 358
 				'type' => 'checkbox',
359 359
 			),
360 360
 			array(
361
-				'name' => __( 'Randomize Gravatars', 'give' ),
362
-				'desc' => __( 'Randomize the Gravatars', 'give' ),
361
+				'name' => __('Randomize Gravatars', 'give'),
362
+				'desc' => __('Randomize the Gravatars', 'give'),
363 363
 				'id'   => 'give_donators_gravatars_random_gravatars',
364 364
 				'type' => 'checkbox',
365 365
 			),
366 366
 		);
367 367
 
368
-		return array_merge( $settings, $give_gravatar_settings );
368
+		return array_merge($settings, $give_gravatar_settings);
369 369
 	}
370 370
 
371 371
 }
@@ -383,12 +383,12 @@  discard block
 block discarded – undo
383 383
 	 */
384 384
 	function give_donators_gravatars_widget() {
385 385
 
386
-		$give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null;
386
+		$give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null;
387 387
 
388 388
 		// widget settings
389 389
 		$widget_ops = array(
390 390
 			'classname'   => 'give-donators-gravatars',
391
-			'description' => sprintf( __( 'Displays gravatars of people who have donated using your your %s. Will only show on the single %s page.', 'give' ), $give_label_singular, $give_label_singular )
391
+			'description' => sprintf(__('Displays gravatars of people who have donated using your your %s. Will only show on the single %s page.', 'give'), $give_label_singular, $give_label_singular)
392 392
 		);
393 393
 
394 394
 		// widget control settings
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 		// create the widget
402 402
 		$this->WP_Widget(
403 403
 			'give_donators_gravatars_widget',
404
-			__( 'Give Donators Gravatars', 'give' ),
404
+			__('Give Donators Gravatars', 'give'),
405 405
 			$widget_ops,
406 406
 			$control_ops
407 407
 		);
@@ -412,29 +412,29 @@  discard block
 block discarded – undo
412 412
 	/*
413 413
 	 * Outputs the content of the widget
414 414
 	 */
415
-	function widget( $args, $instance ) {
415
+	function widget($args, $instance) {
416 416
 		global $give_options;
417 417
 
418
-		extract( $args );
418
+		extract($args);
419 419
 
420
-		if ( ! is_singular( 'give_forms' ) ) {
420
+		if ( ! is_singular('give_forms')) {
421 421
 			return;
422 422
 		}
423 423
 
424 424
 		// Variables from widget settings
425
-		$title = apply_filters( 'widget_title', $instance['title'] );
425
+		$title = apply_filters('widget_title', $instance['title']);
426 426
 
427 427
 		// Used by themes. Opens the widget
428 428
 		echo $before_widget;
429 429
 
430 430
 		// Display the widget title
431
-		if ( $title ) {
432
-			echo $before_title . $title . $after_title;
431
+		if ($title) {
432
+			echo $before_title.$title.$after_title;
433 433
 		}
434 434
 
435 435
 		$gravatars = new Give_Donators_Gravatars();
436 436
 
437
-		echo $gravatars->gravatars( get_the_ID(), null ); // remove title
437
+		echo $gravatars->gravatars(get_the_ID(), null); // remove title
438 438
 
439 439
 		// Used by themes. Closes the widget
440 440
 		echo $after_widget;
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
 	/*
445 445
 	 * Update function. Processes widget options to be saved
446 446
 	 */
447
-	function update( $new_instance, $old_instance ) {
447
+	function update($new_instance, $old_instance) {
448 448
 
449 449
 		$instance = $old_instance;
450 450
 
451
-		$instance['title'] = strip_tags( $new_instance['title'] );
451
+		$instance['title'] = strip_tags($new_instance['title']);
452 452
 
453 453
 		return $instance;
454 454
 
@@ -457,19 +457,19 @@  discard block
 block discarded – undo
457 457
 	/*
458 458
 	 * Form function. Displays the actual form on the widget page
459 459
 	 */
460
-	function form( $instance ) {
460
+	function form($instance) {
461 461
 
462 462
 		// Set up some default widget settings.
463 463
 		$defaults = array(
464 464
 			'title' => '',
465 465
 		);
466 466
 
467
-		$instance = wp_parse_args( (array) $instance, $defaults ); ?>
467
+		$instance = wp_parse_args((array) $instance, $defaults); ?>
468 468
 
469 469
 		<!-- Title -->
470 470
 		<p>
471
-			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'give' ) ?></label>
472
-			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" />
471
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'give') ?></label>
472
+			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
473 473
 		</p>
474 474
 
475 475
 
Please login to merge, or discard this patch.
includes/gateways/manual.php 1 patch
Spacing   +12 added lines, -12 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
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @since 1.0
21 21
  * @return void
22 22
  */
23
-add_action( 'give_manual_cc_form', '__return_false' );
23
+add_action('give_manual_cc_form', '__return_false');
24 24
 
25 25
 /**
26 26
  * Processes the purchase data and uses the Manual Payment gateway to record
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return void
34 34
  */
35
-function give_manual_payment( $purchase_data ) {
35
+function give_manual_payment($purchase_data) {
36 36
 
37
-	if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) {
38
-		wp_die( __( 'Nonce verification has failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
37
+	if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) {
38
+		wp_die(__('Nonce verification has failed', 'give'), __('Error', 'give'), array('response' => 403));
39 39
 	}
40 40
 	
41 41
 	//Create payment_data array
42 42
 	$payment_data = array(
43 43
 		'price'           => $purchase_data['price'],
44 44
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
45
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
45
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
46 46
 		'give_price_id'   => $purchase_data['post_data']['give-price-id'],
47 47
 		'date'            => $purchase_data['date'],
48 48
 		'user_email'      => $purchase_data['user_email'],
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
 		'status'          => 'pending'
53 53
 	);
54 54
 	// Record the pending payment
55
-	$payment = give_insert_payment( $payment_data );
55
+	$payment = give_insert_payment($payment_data);
56 56
 
57
-	if ( $payment ) {
58
-		give_update_payment_status( $payment, 'publish' );
57
+	if ($payment) {
58
+		give_update_payment_status($payment, 'publish');
59 59
 		give_send_to_success_page();
60 60
 	} else {
61
-		give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( __( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment );
61
+		give_record_gateway_error(__('Payment Error', 'give'), sprintf(__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), json_encode($payment_data)), $payment);
62 62
 		// If errors are present, send the user back to the purchase page so they can be corrected
63
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
63
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
64 64
 	}
65 65
 }
66 66
 
67
-add_action( 'give_gateway_manual', 'give_manual_payment' );
67
+add_action('give_gateway_manual', 'give_manual_payment');
Please login to merge, or discard this patch.