Completed
Pull Request — master (#686)
by Devin
42:59 queued 23:02
created
includes/payments/class-payment-stats.php 1 patch
Spacing   +46 added lines, -46 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
 
@@ -39,35 +39,35 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @return float|int  Total amount of donations based on the passed arguments.
41 41
 	 */
42
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
42
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
43 43
 
44
-		$this->setup_dates( $start_date, $end_date );
44
+		$this->setup_dates($start_date, $end_date);
45 45
 
46 46
 		// Make sure start date is valid
47
-		if ( is_wp_error( $this->start_date ) ) {
47
+		if (is_wp_error($this->start_date)) {
48 48
 			return $this->start_date;
49 49
 		}
50 50
 
51 51
 		// Make sure end date is valid
52
-		if ( is_wp_error( $this->end_date ) ) {
52
+		if (is_wp_error($this->end_date)) {
53 53
 			return $this->end_date;
54 54
 		}
55 55
 
56
-		if ( empty( $form_id ) ) {
56
+		if (empty($form_id)) {
57 57
 
58 58
 			// Global sale stats
59
-			add_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
59
+			add_filter('give_count_payments_where', array($this, 'count_where'));
60 60
 
61
-			if ( is_array( $status ) ) {
61
+			if (is_array($status)) {
62 62
 				$count = 0;
63
-				foreach ( $status as $payment_status ) {
63
+				foreach ($status as $payment_status) {
64 64
 					$count += give_count_payments()->$payment_status;
65 65
 				}
66 66
 			} else {
67 67
 				$count = give_count_payments()->$status;
68 68
 			}
69 69
 
70
-			remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
70
+			remove_filter('give_count_payments_where', array($this, 'count_where'));
71 71
 
72 72
 		} else {
73 73
 
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 			// Product specific stats
77 77
 			global $give_logs;
78 78
 
79
-			add_filter( 'posts_where', array( $this, 'payments_where' ) );
79
+			add_filter('posts_where', array($this, 'payments_where'));
80 80
 
81
-			$count = $give_logs->get_log_count( $form_id, 'sale' );
81
+			$count = $give_logs->get_log_count($form_id, 'sale');
82 82
 
83
-			remove_filter( 'posts_where', array( $this, 'payments_where' ) );
83
+			remove_filter('posts_where', array($this, 'payments_where'));
84 84
 
85 85
 		}
86 86
 
@@ -102,31 +102,31 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return float|int Total amount of donations based on the passed arguments.
104 104
 	 */
105
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
105
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
106 106
 
107 107
 		global $wpdb;
108 108
 
109
-		$this->setup_dates( $start_date, $end_date );
109
+		$this->setup_dates($start_date, $end_date);
110 110
 
111 111
 		// Make sure start date is valid
112
-		if ( is_wp_error( $this->start_date ) ) {
112
+		if (is_wp_error($this->start_date)) {
113 113
 			return $this->start_date;
114 114
 		}
115 115
 
116 116
 		// Make sure end date is valid
117
-		if ( is_wp_error( $this->end_date ) ) {
117
+		if (is_wp_error($this->end_date)) {
118 118
 			return $this->end_date;
119 119
 		}
120 120
 
121
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
121
+		add_filter('posts_where', array($this, 'payments_where'));
122 122
 
123
-		if ( empty( $form_id ) ) {
123
+		if (empty($form_id)) {
124 124
 
125 125
 			// Global earning stats
126 126
 			$args = array(
127 127
 				'post_type'              => 'give_payment',
128 128
 				'nopaging'               => true,
129
-				'post_status'            => array( 'publish' ),
129
+				'post_status'            => array('publish'),
130 130
 				'fields'                 => 'ids',
131 131
 				'update_post_term_cache' => false,
132 132
 				'suppress_filters'       => false,
@@ -138,24 +138,24 @@  discard block
 block discarded – undo
138 138
 			);
139 139
 
140 140
 			//Filter by Gateway ID meta_key
141
-			if ( $gateway_id !== false ) {
141
+			if ($gateway_id !== false) {
142 142
 				$args['meta_key']   = '_give_payment_gateway';
143 143
 				$args['meta_value'] = $gateway_id;
144 144
 			}
145 145
 
146
-			$args = apply_filters( 'give_stats_earnings_args', $args );
147
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
148
-			$earnings = get_transient( $key );
146
+			$args = apply_filters('give_stats_earnings_args', $args);
147
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
148
+			$earnings = get_transient($key);
149 149
 			
150
-			if ( false === $earnings ) {
151
-				$sales    = get_posts( $args );
150
+			if (false === $earnings) {
151
+				$sales    = get_posts($args);
152 152
 				$earnings = 0;
153
-				if ( $sales ) {
154
-					$sales = implode( ',', array_map('intval', $sales ) );
155
-					$earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" );
153
+				if ($sales) {
154
+					$sales = implode(',', array_map('intval', $sales));
155
+					$earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})");
156 156
 				}
157 157
 				// Cache the results for one hour
158
-				set_transient( $key, $earnings, HOUR_IN_SECONDS );
158
+				set_transient($key, $earnings, HOUR_IN_SECONDS);
159 159
 			}
160 160
 
161 161
 		} else {
@@ -175,37 +175,37 @@  discard block
 block discarded – undo
175 175
 				'give_transient_type' => 'give_earnings',
176 176
 				// This is not a valid query arg, but is used for cache keying
177 177
 			);
178
-			$args = apply_filters( 'give_stats_earnings_args', $args );
179
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
178
+			$args = apply_filters('give_stats_earnings_args', $args);
179
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
180 180
 			//Set transient for faster stats
181
-			$earnings = get_transient( $key );
181
+			$earnings = get_transient($key);
182 182
 
183
-			if ( false === $earnings ) {
183
+			if (false === $earnings) {
184 184
 
185 185
 				$this->timestamp = false;
186
-				$log_ids  = $give_logs->get_connected_logs( $args, 'sale' );
186
+				$log_ids  = $give_logs->get_connected_logs($args, 'sale');
187 187
 				$earnings = 0;
188 188
 
189
-				if ( $log_ids ) {
190
-					$log_ids     = implode( ',', array_map('intval', $log_ids ) );
191
-					$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" );
189
+				if ($log_ids) {
190
+					$log_ids     = implode(',', array_map('intval', $log_ids));
191
+					$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);");
192 192
 
193
-					foreach ( $payment_ids as $payment_id ) {
194
-						$earnings += give_get_payment_amount( $payment_id );
193
+					foreach ($payment_ids as $payment_id) {
194
+						$earnings += give_get_payment_amount($payment_id);
195 195
 					}
196 196
 					
197 197
 				}
198 198
 
199 199
 				// Cache the results for one hour
200
-				set_transient( $key, $earnings, 60 * 60 );
200
+				set_transient($key, $earnings, 60 * 60);
201 201
 			}
202 202
 		}
203 203
 
204 204
 		//remove our filter
205
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
205
+		remove_filter('posts_where', array($this, 'payments_where'));
206 206
 
207 207
 		//return earnings
208
-		return round( $earnings, give_currency_decimal_filter() );
208
+		return round($earnings, give_currency_decimal_filter());
209 209
 
210 210
 	}
211 211
 
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
 	 *
220 220
 	 * @return array
221 221
 	 */
222
-	public function get_best_selling( $number = 10 ) {
222
+	public function get_best_selling($number = 10) {
223 223
 
224 224
 		global $wpdb;
225 225
 
226
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
226
+		$give_forms = $wpdb->get_results($wpdb->prepare(
227 227
 			"SELECT post_id as form_id, max(meta_value) as sales
228 228
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
229 229
 				GROUP BY meta_value+0
230 230
 				DESC LIMIT %d;", $number
231
-		) );
231
+		));
232 232
 
233 233
 		return $give_forms;
234 234
 	}
Please login to merge, or discard this patch.
includes/deprecated-functions.php 1 patch
Spacing   +8 added lines, -8 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' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return bool $ret True if guest checkout is enabled, false otherwise
30 30
  */
31
-function give_no_guest_checkout( $form_id ) {
31
+function give_no_guest_checkout($form_id) {
32 32
 
33 33
 	$backtrace = debug_backtrace();
34 34
 
35
-	_give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace );
35
+	_give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace);
36 36
 
37
-	$ret = get_post_meta( $form_id, '_give_logged_in_only', true );
37
+	$ret = get_post_meta($form_id, '_give_logged_in_only', true);
38 38
 
39
-	return (bool) apply_filters( 'give_no_guest_checkout', $ret );
39
+	return (bool) apply_filters('give_no_guest_checkout', $ret);
40 40
 }
41 41
 
42 42
 /**
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
  *
51 51
  * @return void
52 52
  */
53
-function give_undo_donation_on_refund( $payment_id, $new_status, $old_status ) {
53
+function give_undo_donation_on_refund($payment_id, $new_status, $old_status) {
54 54
 
55 55
 	$backtrace = debug_backtrace();
56
-	_give_deprecated_function( 'give_undo_purchase_on_refund', '1.5', 'Give_Payment->refund()', $backtrace );
56
+	_give_deprecated_function('give_undo_purchase_on_refund', '1.5', 'Give_Payment->refund()', $backtrace);
57 57
 
58
-	$payment = new Give_Payment( $payment_id );
58
+	$payment = new Give_Payment($payment_id);
59 59
 	$payment->refund();
60 60
 
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-forms.php 1 patch
Spacing   +53 added lines, -53 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' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 	public function csv_cols() {
42 42
 
43 43
 		$cols = array(
44
-			'ID'                      => __( 'ID', 'give' ),
45
-			'post_name'               => __( 'Slug', 'give' ),
46
-			'post_title'              => __( 'Name', 'give' ),
47
-			'post_date'               => __( 'Date Created', 'give' ),
48
-			'post_author'             => __( 'Author', 'give' ),
49
-			'post_content'            => __( 'Description', 'give' ),
50
-			'post_excerpt'            => __( 'Excerpt', 'give' ),
51
-			'post_status'             => __( 'Status', 'give' ),
52
-			'categories'              => __( 'Categories', 'give' ),
53
-			'tags'                    => __( 'Tags', 'give' ),
54
-			'give_price'              => __( 'Price', 'give' ),
55
-			'_thumbnail_id'           => __( 'Featured Image', 'give' ),
56
-			'_give_form_sales'        => __( 'Donations', 'give' ),
57
-			'_give_download_earnings' => __( 'Income', 'give' ),
44
+			'ID'                      => __('ID', 'give'),
45
+			'post_name'               => __('Slug', 'give'),
46
+			'post_title'              => __('Name', 'give'),
47
+			'post_date'               => __('Date Created', 'give'),
48
+			'post_author'             => __('Author', 'give'),
49
+			'post_content'            => __('Description', 'give'),
50
+			'post_excerpt'            => __('Excerpt', 'give'),
51
+			'post_status'             => __('Status', 'give'),
52
+			'categories'              => __('Categories', 'give'),
53
+			'tags'                    => __('Tags', 'give'),
54
+			'give_price'              => __('Price', 'give'),
55
+			'_thumbnail_id'           => __('Featured Image', 'give'),
56
+			'_give_form_sales'        => __('Donations', 'give'),
57
+			'_give_download_earnings' => __('Income', 'give'),
58 58
 		);
59 59
 
60 60
 		return $cols;
@@ -86,43 +86,43 @@  discard block
 block discarded – undo
86 86
 			'paged'          => $this->step
87 87
 		);
88 88
 
89
-		$downloads = new WP_Query( $args );
89
+		$downloads = new WP_Query($args);
90 90
 
91
-		if ( $downloads->posts ) {
92
-			foreach ( $downloads->posts as $download ) {
91
+		if ($downloads->posts) {
92
+			foreach ($downloads->posts as $download) {
93 93
 
94 94
 				$row = array();
95 95
 
96
-				foreach ( $this->csv_cols() as $key => $value ) {
96
+				foreach ($this->csv_cols() as $key => $value) {
97 97
 
98 98
 					// Setup default value
99
-					$row[ $key ] = '';
99
+					$row[$key] = '';
100 100
 
101
-					if ( in_array( $key, $meta ) ) {
101
+					if (in_array($key, $meta)) {
102 102
 
103
-						switch ( $key ) {
103
+						switch ($key) {
104 104
 
105 105
 							case '_thumbnail_id' :
106 106
 
107
-								$image_id    = get_post_thumbnail_id( $download->ID );
108
-								$row[ $key ] = wp_get_attachment_url( $image_id );
107
+								$image_id    = get_post_thumbnail_id($download->ID);
108
+								$row[$key] = wp_get_attachment_url($image_id);
109 109
 
110 110
 								break;
111 111
 
112 112
 							case 'give_price' :
113 113
 
114
-								if ( give_has_variable_prices( $download->ID ) ) {
114
+								if (give_has_variable_prices($download->ID)) {
115 115
 
116 116
 									$prices = array();
117
-									foreach ( give_get_variable_prices( $download->ID ) as $price ) {
118
-										$prices[] = $price['name'] . ': ' . $price['amount'];
117
+									foreach (give_get_variable_prices($download->ID) as $price) {
118
+										$prices[] = $price['name'].': '.$price['amount'];
119 119
 									}
120 120
 
121
-									$row[ $key ] = implode( ' | ', $prices );
121
+									$row[$key] = implode(' | ', $prices);
122 122
 
123 123
 								} else {
124 124
 
125
-									$row[ $key ] = give_get_download_price( $download->ID );
125
+									$row[$key] = give_get_download_price($download->ID);
126 126
 
127 127
 								}
128 128
 
@@ -132,54 +132,54 @@  discard block
 block discarded – undo
132 132
 
133 133
 
134 134
 								$files = array();
135
-								foreach ( give_get_download_files( $download->ID ) as $file ) {
135
+								foreach (give_get_download_files($download->ID) as $file) {
136 136
 									$files[] = $file['file'];
137 137
 								}
138 138
 
139
-								$row[ $key ] = implode( ' | ', $files );
139
+								$row[$key] = implode(' | ', $files);
140 140
 
141 141
 								break;
142 142
 
143 143
 							default :
144 144
 
145
-								$row[ $key ] = get_post_meta( $download->ID, $key, true );
145
+								$row[$key] = get_post_meta($download->ID, $key, true);
146 146
 
147 147
 								break;
148 148
 
149 149
 						}
150 150
 
151
-					} elseif ( isset( $download->$key ) ) {
151
+					} elseif (isset($download->$key)) {
152 152
 
153
-						switch ( $key ) {
153
+						switch ($key) {
154 154
 
155 155
 							case 'post_author' :
156 156
 
157
-								$row[ $key ] = get_the_author_meta( 'user_login', $download->post_author );
157
+								$row[$key] = get_the_author_meta('user_login', $download->post_author);
158 158
 
159 159
 								break;
160 160
 
161 161
 							default :
162 162
 
163
-								$row[ $key ] = $download->$key;
163
+								$row[$key] = $download->$key;
164 164
 
165 165
 								break;
166 166
 						}
167 167
 
168
-					} elseif ( 'tags' == $key ) {
168
+					} elseif ('tags' == $key) {
169 169
 
170
-						$terms = get_the_terms( $download->ID, 'download_tag' );
171
-						if ( $terms ) {
172
-							$terms       = wp_list_pluck( $terms, 'name' );
173
-							$row[ $key ] = implode( ' | ', $terms );
170
+						$terms = get_the_terms($download->ID, 'download_tag');
171
+						if ($terms) {
172
+							$terms       = wp_list_pluck($terms, 'name');
173
+							$row[$key] = implode(' | ', $terms);
174 174
 						}
175 175
 
176 176
 
177
-					} elseif ( 'categories' == $key ) {
177
+					} elseif ('categories' == $key) {
178 178
 
179
-						$terms = get_the_terms( $download->ID, 'download_category' );
180
-						if ( $terms ) {
181
-							$terms       = wp_list_pluck( $terms, 'name' );
182
-							$row[ $key ] = implode( ' | ', $terms );
179
+						$terms = get_the_terms($download->ID, 'download_category');
180
+						if ($terms) {
181
+							$terms       = wp_list_pluck($terms, 'name');
182
+							$row[$key] = implode(' | ', $terms);
183 183
 						}
184 184
 
185 185
 					}
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 
191 191
 			}
192 192
 
193
-			$data = apply_filters( 'give_export_get_data', $data );
194
-			$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
193
+			$data = apply_filters('give_export_get_data', $data);
194
+			$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
195 195
 
196 196
 			return $data;
197 197
 		}
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$args = array(
212 212
 			'post_type'      => 'give_forms',
213
-			'posts_per_page' => - 1,
213
+			'posts_per_page' => -1,
214 214
 			'post_status'    => 'any',
215 215
 			'fields'         => 'ids',
216 216
 		);
217 217
 
218
-		$downloads  = new WP_Query( $args );
218
+		$downloads  = new WP_Query($args);
219 219
 		$total      = (int) $downloads->post_count;
220 220
 		$percentage = 100;
221 221
 
222
-		if ( $total > 0 ) {
223
-			$percentage = ( ( 30 * $this->step ) / $total ) * 100;
222
+		if ($total > 0) {
223
+			$percentage = ((30 * $this->step) / $total) * 100;
224 224
 		}
225 225
 
226
-		if ( $percentage > 100 ) {
226
+		if ($percentage > 100) {
227 227
 			$percentage = 100;
228 228
 		}
229 229
 
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-payments.php 1 patch
Spacing   +80 added lines, -80 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' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -39,29 +39,29 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function csv_cols() {
41 41
 		$cols = array(
42
-			'id'       => __( 'ID', 'give' ), // unaltered payment ID (use for querying)
43
-			'seq_id'   => __( 'Payment Number', 'give' ), // sequential payment ID
44
-			'email'    => __( 'Email', 'give' ),
45
-			'first'    => __( 'First Name', 'give' ),
46
-			'last'     => __( 'Last Name', 'give' ),
47
-			'address1' => __( 'Address', 'give' ),
48
-			'address2' => __( 'Address (Line 2)', 'give' ),
49
-			'city'     => __( 'City', 'give' ),
50
-			'state'    => __( 'State', 'give' ),
51
-			'country'  => __( 'Country', 'give' ),
52
-			'zip'      => __( 'Zip / Postal Code', 'give' ),
53
-			'products' => __( 'Products', 'give' ),
54
-			'amount'   => __( 'Amount', 'give' ) . ' (' . html_entity_decode( give_currency_filter( '' ) ) . ')',
55
-			'gateway'  => __( 'Payment Method', 'give' ),
56
-			'trans_id' => __( 'Transaction ID', 'give' ),
57
-			'key'      => __( 'Purchase Key', 'give' ),
58
-			'date'     => __( 'Date', 'give' ),
59
-			'user'     => __( 'User', 'give' ),
60
-			'status'   => __( 'Status', 'give' )
42
+			'id'       => __('ID', 'give'), // unaltered payment ID (use for querying)
43
+			'seq_id'   => __('Payment Number', 'give'), // sequential payment ID
44
+			'email'    => __('Email', 'give'),
45
+			'first'    => __('First Name', 'give'),
46
+			'last'     => __('Last Name', 'give'),
47
+			'address1' => __('Address', 'give'),
48
+			'address2' => __('Address (Line 2)', 'give'),
49
+			'city'     => __('City', 'give'),
50
+			'state'    => __('State', 'give'),
51
+			'country'  => __('Country', 'give'),
52
+			'zip'      => __('Zip / Postal Code', 'give'),
53
+			'products' => __('Products', 'give'),
54
+			'amount'   => __('Amount', 'give').' ('.html_entity_decode(give_currency_filter('')).')',
55
+			'gateway'  => __('Payment Method', 'give'),
56
+			'trans_id' => __('Transaction ID', 'give'),
57
+			'key'      => __('Purchase Key', 'give'),
58
+			'date'     => __('Date', 'give'),
59
+			'user'     => __('User', 'give'),
60
+			'status'   => __('Status', 'give')
61 61
 		);
62 62
 
63
-		if ( ! give_get_option( 'enable_sequential' ) ) {
64
-			unset( $cols['seq_id'] );
63
+		if ( ! give_get_option('enable_sequential')) {
64
+			unset($cols['seq_id']);
65 65
 		}
66 66
 
67 67
 		return $cols;
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 			'status' => $this->status
88 88
 		);
89 89
 
90
-		if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
90
+		if ( ! empty($this->start) || ! empty($this->end)) {
91 91
 
92 92
 			$args['date_query'] = array(
93 93
 				array(
94
-					'after'     => date( 'Y-n-d 00:00:00', strtotime( $this->start ) ),
95
-					'before'    => date( 'Y-n-d 23:59:59', strtotime( $this->end ) ),
94
+					'after'     => date('Y-n-d 00:00:00', strtotime($this->start)),
95
+					'before'    => date('Y-n-d 23:59:59', strtotime($this->end)),
96 96
 					'inclusive' => true
97 97
 				)
98 98
 			);
@@ -101,104 +101,104 @@  discard block
 block discarded – undo
101 101
 
102 102
 		//echo json_encode($args ); exit;
103 103
 
104
-		$payments = give_get_payments( $args );
104
+		$payments = give_get_payments($args);
105 105
 
106
-		if ( $payments ) {
106
+		if ($payments) {
107 107
 
108
-			foreach ( $payments as $payment ) {
109
-				$payment_meta = give_get_payment_meta( $payment->ID );
110
-				$user_info    = give_get_payment_meta_user_info( $payment->ID );
111
-				$total        = give_get_payment_amount( $payment->ID );
112
-				$user_id      = isset( $user_info['id'] ) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email'];
108
+			foreach ($payments as $payment) {
109
+				$payment_meta = give_get_payment_meta($payment->ID);
110
+				$user_info    = give_get_payment_meta_user_info($payment->ID);
111
+				$total        = give_get_payment_amount($payment->ID);
112
+				$user_id      = isset($user_info['id']) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email'];
113 113
 				$products     = '';
114 114
 				$skus         = '';
115 115
 
116
-				if ( $downloads ) {
117
-					foreach ( $downloads as $key => $download ) {
116
+				if ($downloads) {
117
+					foreach ($downloads as $key => $download) {
118 118
 
119 119
 						// Form ID
120
-						$id  = isset( $payment_meta['cart_details'] ) ? $download['id'] : $download;
121
-						$qty = isset( $download['quantity'] ) ? $download['quantity'] : 1;
120
+						$id  = isset($payment_meta['cart_details']) ? $download['id'] : $download;
121
+						$qty = isset($download['quantity']) ? $download['quantity'] : 1;
122 122
 
123
-						if ( isset( $download['price'] ) ) {
123
+						if (isset($download['price'])) {
124 124
 							$price = $download['price'];
125 125
 						} else {
126 126
 							// If the download has variable prices, override the default price
127
-							$price_override = isset( $payment_meta['cart_details'] ) ? $download['price'] : null;
128
-							$price          = give_get_download_final_price( $id, $user_info, $price_override );
127
+							$price_override = isset($payment_meta['cart_details']) ? $download['price'] : null;
128
+							$price          = give_get_download_final_price($id, $user_info, $price_override);
129 129
 						}
130 130
 
131 131
 
132 132
 						// Display the Downoad Name
133
-						$products .= html_entity_decode( get_the_title( $id ) );
133
+						$products .= html_entity_decode(get_the_title($id));
134 134
 
135
-						if ( $qty > 1 ) {
136
-							$products .= html_entity_decode( ' (' . $qty . ')' );
135
+						if ($qty > 1) {
136
+							$products .= html_entity_decode(' ('.$qty.')');
137 137
 						}
138 138
 
139 139
 						$products .= ' - ';
140 140
 
141
-						if ( give_use_skus() ) {
142
-							$sku = give_get_download_sku( $id );
141
+						if (give_use_skus()) {
142
+							$sku = give_get_download_sku($id);
143 143
 
144
-							if ( ! empty( $sku ) ) {
144
+							if ( ! empty($sku)) {
145 145
 								$skus .= $sku;
146 146
 							}
147 147
 						}
148 148
 
149
-						if ( isset( $downloads[ $key ]['item_number'] ) && isset( $downloads[ $key ]['item_number']['options'] ) ) {
150
-							$price_options = $downloads[ $key ]['item_number']['options'];
149
+						if (isset($downloads[$key]['item_number']) && isset($downloads[$key]['item_number']['options'])) {
150
+							$price_options = $downloads[$key]['item_number']['options'];
151 151
 
152
-							if ( isset( $price_options['price_id'] ) ) {
153
-								$products .= html_entity_decode( give_get_price_option_name( $id, $price_options['price_id'], $payment->ID ) ) . ' - ';
152
+							if (isset($price_options['price_id'])) {
153
+								$products .= html_entity_decode(give_get_price_option_name($id, $price_options['price_id'], $payment->ID)).' - ';
154 154
 							}
155 155
 						}
156 156
 
157
-						$products .= html_entity_decode( give_currency_filter( give_format_amount( $price ) ) );
157
+						$products .= html_entity_decode(give_currency_filter(give_format_amount($price)));
158 158
 
159
-						if ( $key != ( count( $downloads ) - 1 ) ) {
159
+						if ($key != (count($downloads) - 1)) {
160 160
 							$products .= ' / ';
161 161
 
162
-							if ( give_use_skus() ) {
162
+							if (give_use_skus()) {
163 163
 								$skus .= ' / ';
164 164
 							}
165 165
 						}
166 166
 					}
167 167
 				}
168 168
 
169
-				if ( is_numeric( $user_id ) ) {
170
-					$user = get_userdata( $user_id );
169
+				if (is_numeric($user_id)) {
170
+					$user = get_userdata($user_id);
171 171
 				} else {
172 172
 					$user = false;
173 173
 				}
174 174
 
175 175
 				$data[] = array(
176 176
 					'id'       => $payment->ID,
177
-					'seq_id'   => give_get_payment_number( $payment->ID ),
177
+					'seq_id'   => give_get_payment_number($payment->ID),
178 178
 					'email'    => $payment_meta['email'],
179 179
 					'first'    => $user_info['first_name'],
180 180
 					'last'     => $user_info['last_name'],
181
-					'address1' => isset( $user_info['address']['line1'] ) ? $user_info['address']['line1'] : '',
182
-					'address2' => isset( $user_info['address']['line2'] ) ? $user_info['address']['line2'] : '',
183
-					'city'     => isset( $user_info['address']['city'] ) ? $user_info['address']['city'] : '',
184
-					'state'    => isset( $user_info['address']['state'] ) ? $user_info['address']['state'] : '',
185
-					'country'  => isset( $user_info['address']['country'] ) ? $user_info['address']['country'] : '',
186
-					'zip'      => isset( $user_info['address']['zip'] ) ? $user_info['address']['zip'] : '',
181
+					'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '',
182
+					'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '',
183
+					'city'     => isset($user_info['address']['city']) ? $user_info['address']['city'] : '',
184
+					'state'    => isset($user_info['address']['state']) ? $user_info['address']['state'] : '',
185
+					'country'  => isset($user_info['address']['country']) ? $user_info['address']['country'] : '',
186
+					'zip'      => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '',
187 187
 					'products' => $products,
188 188
 					'skus'     => $skus,
189
-					'amount'   => html_entity_decode( give_format_amount( $total ) ),
190
-					'gateway'  => give_get_gateway_admin_label( get_post_meta( $payment->ID, '_give_payment_gateway', true ) ),
191
-					'trans_id' => give_get_payment_transaction_id( $payment->ID ),
189
+					'amount'   => html_entity_decode(give_format_amount($total)),
190
+					'gateway'  => give_get_gateway_admin_label(get_post_meta($payment->ID, '_give_payment_gateway', true)),
191
+					'trans_id' => give_get_payment_transaction_id($payment->ID),
192 192
 					'key'      => $payment_meta['key'],
193 193
 					'date'     => $payment->post_date,
194
-					'user'     => $user ? $user->display_name : __( 'guest', 'give' ),
195
-					'status'   => give_get_payment_status( $payment, true )
194
+					'user'     => $user ? $user->display_name : __('guest', 'give'),
195
+					'status'   => give_get_payment_status($payment, true)
196 196
 				);
197 197
 
198 198
 			}
199 199
 
200
-			$data = apply_filters( 'give_export_get_data', $data );
201
-			$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
200
+			$data = apply_filters('give_export_get_data', $data);
201
+			$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
202 202
 
203 203
 			return $data;
204 204
 
@@ -218,27 +218,27 @@  discard block
 block discarded – undo
218 218
 
219 219
 		$status = $this->status;
220 220
 		$args   = array(
221
-			'start-date' => date( 'n/d/Y', strtotime( $this->start ) ),
222
-			'end-date'   => date( 'n/d/Y', strtotime( $this->end ) ),
221
+			'start-date' => date('n/d/Y', strtotime($this->start)),
222
+			'end-date'   => date('n/d/Y', strtotime($this->end)),
223 223
 		);
224 224
 
225
-		if ( 'any' == $status ) {
225
+		if ('any' == $status) {
226 226
 
227
-			$total = array_sum( (array) give_count_payments( $args ) );
227
+			$total = array_sum((array) give_count_payments($args));
228 228
 
229 229
 		} else {
230 230
 
231
-			$total = give_count_payments( $args )->$status;
231
+			$total = give_count_payments($args)->$status;
232 232
 
233 233
 		}
234 234
 
235 235
 		$percentage = 100;
236 236
 
237
-		if ( $total > 0 ) {
238
-			$percentage = ( ( 30 * $this->step ) / $total ) * 100;
237
+		if ($total > 0) {
238
+			$percentage = ((30 * $this->step) / $total) * 100;
239 239
 		}
240 240
 
241
-		if ( $percentage > 100 ) {
241
+		if ($percentage > 100) {
242 242
 			$percentage = 100;
243 243
 		}
244 244
 
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @param array $request The Form Data passed into the batch processing
254 254
 	 */
255
-	public function set_properties( $request ) {
256
-		$this->start  = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : '';
257
-		$this->end    = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : '';
258
-		$this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete';
255
+	public function set_properties($request) {
256
+		$this->start  = isset($request['start']) ? sanitize_text_field($request['start']) : '';
257
+		$this->end    = isset($request['end']) ? sanitize_text_field($request['end']) : '';
258
+		$this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete';
259 259
 	}
260 260
 }
Please login to merge, or discard this patch.
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/export/export-functions.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  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
 
18
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export.php';
19
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php';
18
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export.php';
19
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-actions.php';
20 20
 
21 21
 /**
22 22
  * Process batch exports via ajax
@@ -26,79 +26,79 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_do_ajax_export() {
28 28
 
29
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
29
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php';
30 30
 
31
-	parse_str( $_POST['form'], $form );
31
+	parse_str($_POST['form'], $form);
32 32
 
33 33
 	$_REQUEST = $form = (array) $form;
34 34
 
35
-	if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) {
36
-		die( '-2' );
35
+	if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) {
36
+		die('-2');
37 37
 	}
38 38
 
39
-	do_action( 'give_batch_export_class_include', $form['give-export-class'] );
39
+	do_action('give_batch_export_class_include', $form['give-export-class']);
40 40
 
41
-	$step   = absint( $_POST['step'] );
42
-	$class  = sanitize_text_field( $form['give-export-class'] );
41
+	$step   = absint($_POST['step']);
42
+	$class  = sanitize_text_field($form['give-export-class']);
43 43
 
44
-	$export = new $class( $step );
44
+	$export = new $class($step);
45 45
 
46
-	if ( ! $export->can_export() ) {
47
-		die( '-1' );
46
+	if ( ! $export->can_export()) {
47
+		die('-1');
48 48
 	}
49 49
 
50
-	if ( ! $export->is_writable ) {
50
+	if ( ! $export->is_writable) {
51 51
 		$json_args = array(
52 52
 			'error'   => true,
53
-			'message' => __( 'Export location or file not writable', 'give' )
53
+			'message' => __('Export location or file not writable', 'give')
54 54
 		);
55 55
 		echo json_encode($json_args);
56 56
 		exit;
57 57
 	}
58 58
 
59
-	$export->set_properties( $_REQUEST );
59
+	$export->set_properties($_REQUEST);
60 60
 
61 61
 	$export->pre_fetch();
62 62
 
63
-	$ret = $export->process_step( $step );
63
+	$ret = $export->process_step($step);
64 64
 
65 65
 	$percentage = $export->get_percentage_complete();
66 66
 
67
-	if ( $ret ) {
67
+	if ($ret) {
68 68
 
69 69
 		$step += 1;
70
-		echo json_encode( array( 'step' => $step, 'percentage' => $percentage ) );
70
+		echo json_encode(array('step' => $step, 'percentage' => $percentage));
71 71
 		exit;
72 72
 
73
-	} elseif ( true === $export->is_empty ) {
73
+	} elseif (true === $export->is_empty) {
74 74
 
75
-		echo json_encode( array(
75
+		echo json_encode(array(
76 76
 			'error'   => true,
77
-			'message' => __( 'No data found for export parameters', 'give' )
78
-		) );
77
+			'message' => __('No data found for export parameters', 'give')
78
+		));
79 79
 		exit;
80 80
 
81
-	} elseif ( true === $export->done && true === $export->is_void ) {
81
+	} elseif (true === $export->done && true === $export->is_void) {
82 82
 
83
-		$message = ! empty( $export->message ) ? $export->message : __( 'Batch Processing Complete', 'give' );
84
-		echo json_encode( array( 'success' => true, 'message' => $message ) );
83
+		$message = ! empty($export->message) ? $export->message : __('Batch Processing Complete', 'give');
84
+		echo json_encode(array('success' => true, 'message' => $message));
85 85
 		exit;
86 86
 
87 87
 	} else {
88 88
 		
89
-		$args = array_merge( $_REQUEST, array(
89
+		$args = array_merge($_REQUEST, array(
90 90
 			'step'        => $step,
91 91
 			'class'       => $class,
92
-			'nonce'       => wp_create_nonce( 'give-batch-export' ),
92
+			'nonce'       => wp_create_nonce('give-batch-export'),
93 93
 			'give_action' => 'form_batch_export',
94
-		) );
94
+		));
95 95
 
96
-		$download_url = add_query_arg( $args, admin_url() );
96
+		$download_url = add_query_arg($args, admin_url());
97 97
 
98
-		echo json_encode( array( 'step' => 'done', 'url' => $download_url ) );
98
+		echo json_encode(array('step' => 'done', 'url' => $download_url));
99 99
 		exit;
100 100
 
101 101
 	}
102 102
 }
103 103
 
104
-add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' );
104
+add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export');
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.