@@ -12,7 +12,7 @@ discard block |
||
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 | |
@@ -85,28 +85,28 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param array $request The Form Data passed into the batch processing. |
87 | 87 | */ |
88 | - public function set_properties( $request ) { |
|
88 | + public function set_properties($request) { |
|
89 | 89 | |
90 | 90 | // Set data from form submission |
91 | - if ( isset( $_POST['form'] ) ) { |
|
92 | - $this->data = give_clean( wp_parse_args( $_POST['form'] ) ); |
|
91 | + if (isset($_POST['form'])) { |
|
92 | + $this->data = give_clean(wp_parse_args($_POST['form'])); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $this->form = $this->data['forms']; |
96 | - $this->categories = ! empty( $request['give_forms_categories'] ) ? (array) $request['give_forms_categories'] : array(); |
|
97 | - $this->tags = ! empty( $request['give_forms_tags'] ) ? (array) $request['give_forms_tags'] : array(); |
|
98 | - $this->form_id = $this->get_form_ids( $request ); |
|
99 | - $this->price_id = isset( $request['give_price_option'] ) && ( 'all' !== $request['give_price_option'] && '' !== $request['give_price_option'] ) ? absint( $request['give_price_option'] ) : null; |
|
100 | - $this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : ''; |
|
101 | - $this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : ''; |
|
102 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete'; |
|
96 | + $this->categories = ! empty($request['give_forms_categories']) ? (array) $request['give_forms_categories'] : array(); |
|
97 | + $this->tags = ! empty($request['give_forms_tags']) ? (array) $request['give_forms_tags'] : array(); |
|
98 | + $this->form_id = $this->get_form_ids($request); |
|
99 | + $this->price_id = isset($request['give_price_option']) && ('all' !== $request['give_price_option'] && '' !== $request['give_price_option']) ? absint($request['give_price_option']) : null; |
|
100 | + $this->start = isset($request['start']) ? sanitize_text_field($request['start']) : ''; |
|
101 | + $this->end = isset($request['end']) ? sanitize_text_field($request['end']) : ''; |
|
102 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete'; |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Hook to use after setting properties. |
106 | 106 | * |
107 | 107 | * @since 2.1.3 |
108 | 108 | */ |
109 | - do_action( 'give_export_donations_form_data', $this->data ); |
|
109 | + do_action('give_export_donations_form_data', $this->data); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return array|boolean|null $form get all the donation id that need to be exported |
120 | 120 | */ |
121 | - public function get_form_ids( $request = array() ) { |
|
122 | - $form = ! empty( $request['forms'] ) && 0 !== $request['forms'] ? absint( $request['forms'] ) : null; |
|
121 | + public function get_form_ids($request = array()) { |
|
122 | + $form = ! empty($request['forms']) && 0 !== $request['forms'] ? absint($request['forms']) : null; |
|
123 | 123 | |
124 | - $form_ids = ! empty( $request['form_ids'] ) ? sanitize_text_field( $request['form_ids'] ) : null; |
|
124 | + $form_ids = ! empty($request['form_ids']) ? sanitize_text_field($request['form_ids']) : null; |
|
125 | 125 | |
126 | - if ( empty( $form ) && ! empty( $form_ids ) && ( ! empty( $this->categories ) || ! empty( $this->tags ) ) ) { |
|
127 | - $form = explode( ',', $form_ids ); |
|
126 | + if (empty($form) && ! empty($form_ids) && ( ! empty($this->categories) || ! empty($this->tags))) { |
|
127 | + $form = explode(',', $form_ids); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | return $form; |
@@ -141,14 +141,14 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function csv_cols() { |
143 | 143 | |
144 | - $columns = isset( $this->data['give_give_donations_export_option'] ) ? $this->data['give_give_donations_export_option'] : array(); |
|
144 | + $columns = isset($this->data['give_give_donations_export_option']) ? $this->data['give_give_donations_export_option'] : array(); |
|
145 | 145 | |
146 | 146 | // We need columns. |
147 | - if ( empty( $columns ) ) { |
|
147 | + if (empty($columns)) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
151 | - $this->cols = $this->get_cols( $columns ); |
|
151 | + $this->cols = $this->get_cols($columns); |
|
152 | 152 | |
153 | 153 | return $this->cols; |
154 | 154 | } |
@@ -163,83 +163,83 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array |
165 | 165 | */ |
166 | - private function get_cols( $columns ) { |
|
166 | + private function get_cols($columns) { |
|
167 | 167 | |
168 | 168 | $cols = array(); |
169 | 169 | |
170 | - foreach ( $columns as $key => $value ) { |
|
170 | + foreach ($columns as $key => $value) { |
|
171 | 171 | |
172 | - switch ( $key ) { |
|
172 | + switch ($key) { |
|
173 | 173 | case 'donation_id' : |
174 | - $cols['donation_id'] = __( 'Donation ID', 'give' ); |
|
174 | + $cols['donation_id'] = __('Donation ID', 'give'); |
|
175 | 175 | break; |
176 | 176 | case 'seq_id' : |
177 | - $cols['seq_id'] = __( 'Donation Number', 'give' ); |
|
177 | + $cols['seq_id'] = __('Donation Number', 'give'); |
|
178 | 178 | break; |
179 | 179 | case 'first_name' : |
180 | - $cols['first_name'] = __( 'First Name', 'give' ); |
|
180 | + $cols['first_name'] = __('First Name', 'give'); |
|
181 | 181 | break; |
182 | 182 | case 'last_name' : |
183 | - $cols['last_name'] = __( 'Last Name', 'give' ); |
|
183 | + $cols['last_name'] = __('Last Name', 'give'); |
|
184 | 184 | break; |
185 | 185 | case 'email' : |
186 | - $cols['email'] = __( 'Email Address', 'give' ); |
|
186 | + $cols['email'] = __('Email Address', 'give'); |
|
187 | 187 | break; |
188 | 188 | case 'company' : |
189 | - $cols['company'] = __( 'Company Name', 'give' ); |
|
189 | + $cols['company'] = __('Company Name', 'give'); |
|
190 | 190 | break; |
191 | 191 | case 'address' : |
192 | - $cols['address_line1'] = __( 'Address 1', 'give' ); |
|
193 | - $cols['address_line2'] = __( 'Address 2', 'give' ); |
|
194 | - $cols['address_city'] = __( 'City', 'give' ); |
|
195 | - $cols['address_state'] = __( 'State', 'give' ); |
|
196 | - $cols['address_zip'] = __( 'Zip', 'give' ); |
|
197 | - $cols['address_country'] = __( 'Country', 'give' ); |
|
192 | + $cols['address_line1'] = __('Address 1', 'give'); |
|
193 | + $cols['address_line2'] = __('Address 2', 'give'); |
|
194 | + $cols['address_city'] = __('City', 'give'); |
|
195 | + $cols['address_state'] = __('State', 'give'); |
|
196 | + $cols['address_zip'] = __('Zip', 'give'); |
|
197 | + $cols['address_country'] = __('Country', 'give'); |
|
198 | 198 | break; |
199 | 199 | case 'donation_total' : |
200 | - $cols['donation_total'] = __( 'Donation Total', 'give' ); |
|
200 | + $cols['donation_total'] = __('Donation Total', 'give'); |
|
201 | 201 | break; |
202 | 202 | case 'currency_code' : |
203 | - $cols['currency_code'] = __( 'Currency Code', 'give' ); |
|
203 | + $cols['currency_code'] = __('Currency Code', 'give'); |
|
204 | 204 | break; |
205 | 205 | case 'currency_symbol' : |
206 | - $cols['currency_symbol'] = __( 'Currency Symbol', 'give' ); |
|
206 | + $cols['currency_symbol'] = __('Currency Symbol', 'give'); |
|
207 | 207 | break; |
208 | 208 | case 'donation_status' : |
209 | - $cols['donation_status'] = __( 'Donation Status', 'give' ); |
|
209 | + $cols['donation_status'] = __('Donation Status', 'give'); |
|
210 | 210 | break; |
211 | 211 | case 'payment_gateway' : |
212 | - $cols['payment_gateway'] = __( 'Payment Gateway', 'give' ); |
|
212 | + $cols['payment_gateway'] = __('Payment Gateway', 'give'); |
|
213 | 213 | break; |
214 | 214 | case 'form_id' : |
215 | - $cols['form_id'] = __( 'Form ID', 'give' ); |
|
215 | + $cols['form_id'] = __('Form ID', 'give'); |
|
216 | 216 | break; |
217 | 217 | case 'form_title' : |
218 | - $cols['form_title'] = __( 'Form Title', 'give' ); |
|
218 | + $cols['form_title'] = __('Form Title', 'give'); |
|
219 | 219 | break; |
220 | 220 | case 'form_level_id' : |
221 | - $cols['form_level_id'] = __( 'Level ID', 'give' ); |
|
221 | + $cols['form_level_id'] = __('Level ID', 'give'); |
|
222 | 222 | break; |
223 | 223 | case 'form_level_title' : |
224 | - $cols['form_level_title'] = __( 'Level Title', 'give' ); |
|
224 | + $cols['form_level_title'] = __('Level Title', 'give'); |
|
225 | 225 | break; |
226 | 226 | case 'donation_date' : |
227 | - $cols['donation_date'] = __( 'Donation Date', 'give' ); |
|
227 | + $cols['donation_date'] = __('Donation Date', 'give'); |
|
228 | 228 | break; |
229 | 229 | case 'donation_time' : |
230 | - $cols['donation_time'] = __( 'Donation Time', 'give' ); |
|
230 | + $cols['donation_time'] = __('Donation Time', 'give'); |
|
231 | 231 | break; |
232 | 232 | case 'userid' : |
233 | - $cols['userid'] = __( 'User ID', 'give' ); |
|
233 | + $cols['userid'] = __('User ID', 'give'); |
|
234 | 234 | break; |
235 | 235 | case 'donorid' : |
236 | - $cols['donorid'] = __( 'Donor ID', 'give' ); |
|
236 | + $cols['donorid'] = __('Donor ID', 'give'); |
|
237 | 237 | break; |
238 | 238 | case 'donor_ip' : |
239 | - $cols['donor_ip'] = __( 'Donor IP Address', 'give' ); |
|
239 | + $cols['donor_ip'] = __('Donor IP Address', 'give'); |
|
240 | 240 | break; |
241 | 241 | default: |
242 | - $cols[ $key ] = $key; |
|
242 | + $cols[$key] = $key; |
|
243 | 243 | |
244 | 244 | } |
245 | 245 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param array $cols columns name for CSV |
253 | 253 | * @param array $columns columns select by admin to export |
254 | 254 | */ |
255 | - return (array) apply_filters( 'give_export_donation_get_columns_name', $cols, $columns ); |
|
255 | + return (array) apply_filters('give_export_donation_get_columns_name', $cols, $columns); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -264,24 +264,24 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return array $args donation argument |
266 | 266 | */ |
267 | - public function get_donation_argument( $args = array() ) { |
|
267 | + public function get_donation_argument($args = array()) { |
|
268 | 268 | $defaults = array( |
269 | 269 | 'number' => 30, |
270 | 270 | 'page' => $this->step, |
271 | 271 | 'status' => $this->status, |
272 | 272 | ); |
273 | 273 | // Date query. |
274 | - if ( ! empty( $this->start ) || ! empty( $this->end ) ) { |
|
275 | - if ( ! empty( $this->start ) ) { |
|
276 | - $defaults['date_query'][0]['after'] = date( 'Y-n-d 00:00:00', strtotime( $this->start ) ); |
|
274 | + if ( ! empty($this->start) || ! empty($this->end)) { |
|
275 | + if ( ! empty($this->start)) { |
|
276 | + $defaults['date_query'][0]['after'] = date('Y-n-d 00:00:00', strtotime($this->start)); |
|
277 | 277 | } |
278 | - if ( ! empty( $this->end ) ) { |
|
279 | - $defaults['date_query'][0]['before'] = date( 'Y-n-d 00:00:00', strtotime( $this->end ) ); |
|
278 | + if ( ! empty($this->end)) { |
|
279 | + $defaults['date_query'][0]['before'] = date('Y-n-d 00:00:00', strtotime($this->end)); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | - if ( ! empty( $this->form_id ) ) { |
|
284 | - $defaults['give_forms'] = is_array( $this->form_id ) ? $this->form_id : array( $this->form_id ); |
|
283 | + if ( ! empty($this->form_id)) { |
|
284 | + $defaults['give_forms'] = is_array($this->form_id) ? $this->form_id : array($this->form_id); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @since 2.1.3 |
292 | 292 | */ |
293 | - return apply_filters( 'give_export_donations_donation_query_args', wp_parse_args( $args, $defaults ) ); |
|
293 | + return apply_filters('give_export_donations_donation_query_args', wp_parse_args($args, $defaults)); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -309,119 +309,119 @@ discard block |
||
309 | 309 | $data = array(); |
310 | 310 | $i = 0; |
311 | 311 | // Payment query. |
312 | - $payments = give_get_payments( $this->get_donation_argument() ); |
|
312 | + $payments = give_get_payments($this->get_donation_argument()); |
|
313 | 313 | |
314 | - if ( $payments ) { |
|
314 | + if ($payments) { |
|
315 | 315 | |
316 | - foreach ( $payments as $payment ) { |
|
316 | + foreach ($payments as $payment) { |
|
317 | 317 | |
318 | 318 | $columns = $this->csv_cols(); |
319 | - $payment = new Give_Payment( $payment->ID ); |
|
319 | + $payment = new Give_Payment($payment->ID); |
|
320 | 320 | $payment_meta = $payment->payment_meta; |
321 | 321 | $address = $payment->address; |
322 | 322 | |
323 | 323 | // Set columns |
324 | - if ( ! empty( $columns['donation_id'] ) ) { |
|
325 | - $data[ $i ]['donation_id'] = $payment->ID; |
|
324 | + if ( ! empty($columns['donation_id'])) { |
|
325 | + $data[$i]['donation_id'] = $payment->ID; |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( ! empty( $columns['seq_id'] ) ) { |
|
329 | - $data[ $i ]['seq_id'] = Give()->seq_donation_number->get_serial_code( $payment->ID ); |
|
328 | + if ( ! empty($columns['seq_id'])) { |
|
329 | + $data[$i]['seq_id'] = Give()->seq_donation_number->get_serial_code($payment->ID); |
|
330 | 330 | } |
331 | 331 | |
332 | - if ( ! empty( $columns['first_name'] ) ) { |
|
333 | - $data[ $i ]['first_name'] = isset( $payment->first_name ) ? $payment->first_name : ''; |
|
332 | + if ( ! empty($columns['first_name'])) { |
|
333 | + $data[$i]['first_name'] = isset($payment->first_name) ? $payment->first_name : ''; |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( ! empty( $columns['last_name'] ) ) { |
|
337 | - $data[ $i ]['last_name'] = isset( $payment->last_name ) ? $payment->last_name : ''; |
|
336 | + if ( ! empty($columns['last_name'])) { |
|
337 | + $data[$i]['last_name'] = isset($payment->last_name) ? $payment->last_name : ''; |
|
338 | 338 | } |
339 | 339 | |
340 | - if ( ! empty( $columns['email'] ) ) { |
|
341 | - $data[ $i ]['email'] = $payment->email; |
|
340 | + if ( ! empty($columns['email'])) { |
|
341 | + $data[$i]['email'] = $payment->email; |
|
342 | 342 | } |
343 | 343 | |
344 | - if ( ! empty( $columns['company'] ) ) { |
|
345 | - $data[ $i ]['company'] = empty( $payment_meta['_give_donation_company'] ) ? '' : str_replace( "\'", "'", $payment_meta['_give_donation_company'] ); |
|
344 | + if ( ! empty($columns['company'])) { |
|
345 | + $data[$i]['company'] = empty($payment_meta['_give_donation_company']) ? '' : str_replace("\'", "'", $payment_meta['_give_donation_company']); |
|
346 | 346 | } |
347 | 347 | |
348 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
349 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
350 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
351 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
352 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
353 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
354 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
348 | + if ( ! empty($columns['address_line1'])) { |
|
349 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
350 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
351 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
352 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
353 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
354 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
355 | 355 | } |
356 | 356 | |
357 | - if ( ! empty( $columns['donation_total'] ) ) { |
|
358 | - $data[ $i ]['donation_total'] = give_format_amount( give_donation_amount( $payment->ID ) ); |
|
357 | + if ( ! empty($columns['donation_total'])) { |
|
358 | + $data[$i]['donation_total'] = give_format_amount(give_donation_amount($payment->ID)); |
|
359 | 359 | } |
360 | 360 | |
361 | - if ( ! empty( $columns['currency_code'] ) ) { |
|
362 | - $data[ $i ]['currency_code'] = empty( $payment_meta['_give_payment_currency'] ) ? give_get_currency() : $payment_meta['_give_payment_currency']; |
|
361 | + if ( ! empty($columns['currency_code'])) { |
|
362 | + $data[$i]['currency_code'] = empty($payment_meta['_give_payment_currency']) ? give_get_currency() : $payment_meta['_give_payment_currency']; |
|
363 | 363 | } |
364 | 364 | |
365 | - if ( ! empty( $columns['currency_symbol'] ) ) { |
|
366 | - $currency_code = $data[ $i ]['currency_code']; |
|
367 | - $data[ $i ]['currency_symbol'] = give_currency_symbol( $currency_code, true ); |
|
365 | + if ( ! empty($columns['currency_symbol'])) { |
|
366 | + $currency_code = $data[$i]['currency_code']; |
|
367 | + $data[$i]['currency_symbol'] = give_currency_symbol($currency_code, true); |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( ! empty( $columns['donation_status'] ) ) { |
|
371 | - $data[ $i ]['donation_status'] = give_get_payment_status( $payment, true ); |
|
370 | + if ( ! empty($columns['donation_status'])) { |
|
371 | + $data[$i]['donation_status'] = give_get_payment_status($payment, true); |
|
372 | 372 | } |
373 | 373 | |
374 | - if ( ! empty( $columns['payment_gateway'] ) ) { |
|
375 | - $data[ $i ]['payment_gateway'] = $payment->gateway; |
|
374 | + if ( ! empty($columns['payment_gateway'])) { |
|
375 | + $data[$i]['payment_gateway'] = $payment->gateway; |
|
376 | 376 | } |
377 | 377 | |
378 | - if ( ! empty( $columns['form_id'] ) ) { |
|
379 | - $data[ $i ]['form_id'] = $payment->form_id; |
|
378 | + if ( ! empty($columns['form_id'])) { |
|
379 | + $data[$i]['form_id'] = $payment->form_id; |
|
380 | 380 | } |
381 | 381 | |
382 | - if ( ! empty( $columns['form_title'] ) ) { |
|
383 | - $data[ $i ]['form_title'] = get_the_title( $payment->form_id ); |
|
382 | + if ( ! empty($columns['form_title'])) { |
|
383 | + $data[$i]['form_title'] = get_the_title($payment->form_id); |
|
384 | 384 | } |
385 | 385 | |
386 | - if ( ! empty( $columns['form_level_id'] ) ) { |
|
387 | - $data[ $i ]['form_level_id'] = $payment->price_id; |
|
386 | + if ( ! empty($columns['form_level_id'])) { |
|
387 | + $data[$i]['form_level_id'] = $payment->price_id; |
|
388 | 388 | } |
389 | 389 | |
390 | - if ( ! empty( $columns['form_level_title'] ) ) { |
|
391 | - $var_prices = give_has_variable_prices( $payment_meta['form_id'] ); |
|
392 | - if ( empty( $var_prices ) ) { |
|
393 | - $data[ $i ]['form_level_title'] = ''; |
|
390 | + if ( ! empty($columns['form_level_title'])) { |
|
391 | + $var_prices = give_has_variable_prices($payment_meta['form_id']); |
|
392 | + if (empty($var_prices)) { |
|
393 | + $data[$i]['form_level_title'] = ''; |
|
394 | 394 | } else { |
395 | 395 | $prices_atts = ''; |
396 | - if ( $variable_prices = give_get_variable_prices( $payment_meta['form_id'] ) ) { |
|
397 | - foreach ( $variable_prices as $variable_price ) { |
|
398 | - $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'] ); |
|
396 | + if ($variable_prices = give_get_variable_prices($payment_meta['form_id'])) { |
|
397 | + foreach ($variable_prices as $variable_price) { |
|
398 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']); |
|
399 | 399 | } |
400 | 400 | } |
401 | - $data[ $i ]['form_level_title'] = give_get_price_option_name( $payment->form_id, $payment->price_id ); |
|
401 | + $data[$i]['form_level_title'] = give_get_price_option_name($payment->form_id, $payment->price_id); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | - if ( ! empty( $columns['donation_date'] ) ) { |
|
406 | - $payment_date = strtotime( $payment->date ); |
|
407 | - $data[ $i ]['donation_date'] = date( give_date_format(), $payment_date ); |
|
405 | + if ( ! empty($columns['donation_date'])) { |
|
406 | + $payment_date = strtotime($payment->date); |
|
407 | + $data[$i]['donation_date'] = date(give_date_format(), $payment_date); |
|
408 | 408 | } |
409 | 409 | |
410 | - if ( ! empty( $columns['donation_time'] ) ) { |
|
411 | - $payment_date = strtotime( $payment->date ); |
|
412 | - $data[ $i ]['donation_time'] = date_i18n( 'H', $payment_date ) . ':' . date( 'i', $payment_date ); |
|
410 | + if ( ! empty($columns['donation_time'])) { |
|
411 | + $payment_date = strtotime($payment->date); |
|
412 | + $data[$i]['donation_time'] = date_i18n('H', $payment_date).':'.date('i', $payment_date); |
|
413 | 413 | } |
414 | 414 | |
415 | - if ( ! empty( $columns['userid'] ) ) { |
|
416 | - $data[ $i ]['userid'] = $payment->user_id; |
|
415 | + if ( ! empty($columns['userid'])) { |
|
416 | + $data[$i]['userid'] = $payment->user_id; |
|
417 | 417 | } |
418 | 418 | |
419 | - if ( ! empty( $columns['donorid'] ) ) { |
|
420 | - $data[ $i ]['donorid'] = $payment->customer_id; |
|
419 | + if ( ! empty($columns['donorid'])) { |
|
420 | + $data[$i]['donorid'] = $payment->customer_id; |
|
421 | 421 | } |
422 | 422 | |
423 | - if ( ! empty( $columns['donor_ip'] ) ) { |
|
424 | - $data[ $i ]['donor_ip'] = give_get_payment_user_ip( $payment->ID ); |
|
423 | + if ( ! empty($columns['donor_ip'])) { |
|
424 | + $data[$i]['donor_ip'] = give_get_payment_user_ip($payment->ID); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | // Add custom field data. |
@@ -452,15 +452,15 @@ discard block |
||
452 | 452 | ); |
453 | 453 | |
454 | 454 | // Removing above keys... |
455 | - foreach ( $remove_keys as $key ) { |
|
456 | - unset( $columns[ $key ] ); |
|
455 | + foreach ($remove_keys as $key) { |
|
456 | + unset($columns[$key]); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | // Now loop through remaining meta fields. |
460 | - foreach ( $columns as $col ) { |
|
461 | - $field_data = get_post_meta( $payment->ID, $col, true ); |
|
462 | - $data[ $i ][ $col ] = $field_data; |
|
463 | - unset( $columns[ $col ] ); |
|
460 | + foreach ($columns as $col) { |
|
461 | + $field_data = get_post_meta($payment->ID, $col, true); |
|
462 | + $data[$i][$col] = $field_data; |
|
463 | + unset($columns[$col]); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -475,27 +475,27 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return array Donation data |
477 | 477 | */ |
478 | - $data[ $i ] = apply_filters( 'give_export_donation_data', $data[ $i ], $payment, $columns, $this ); |
|
478 | + $data[$i] = apply_filters('give_export_donation_data', $data[$i], $payment, $columns, $this); |
|
479 | 479 | |
480 | 480 | $new_data = array(); |
481 | - $old_data = $data[ $i ]; |
|
481 | + $old_data = $data[$i]; |
|
482 | 482 | |
483 | 483 | // sorting the columns bas on row |
484 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
485 | - if ( array_key_exists( $key, $old_data ) ) { |
|
486 | - $new_data[ $key ] = $old_data[ $key ]; |
|
484 | + foreach ($this->csv_cols() as $key => $value) { |
|
485 | + if (array_key_exists($key, $old_data)) { |
|
486 | + $new_data[$key] = $old_data[$key]; |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | - $data[ $i ] = $new_data; |
|
490 | + $data[$i] = $new_data; |
|
491 | 491 | |
492 | 492 | // Increment iterator. |
493 | - $i ++; |
|
493 | + $i++; |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | |
497 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
498 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
497 | + $data = apply_filters('give_export_get_data', $data); |
|
498 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
499 | 499 | |
500 | 500 | return $data; |
501 | 501 | |
@@ -513,17 +513,17 @@ discard block |
||
513 | 513 | * @return int |
514 | 514 | */ |
515 | 515 | public function get_percentage_complete() { |
516 | - $args = $this->get_donation_argument( array( 'number' => - 1 ) ); |
|
517 | - if ( isset( $args['page'] ) ) { |
|
518 | - unset( $args['page'] ); |
|
516 | + $args = $this->get_donation_argument(array('number' => -1)); |
|
517 | + if (isset($args['page'])) { |
|
518 | + unset($args['page']); |
|
519 | 519 | } |
520 | - $query = give_get_payments( $args ); |
|
521 | - $total = count( $query ); |
|
520 | + $query = give_get_payments($args); |
|
521 | + $total = count($query); |
|
522 | 522 | $percentage = 100; |
523 | - if ( $total > 0 ) { |
|
524 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
523 | + if ($total > 0) { |
|
524 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
525 | 525 | } |
526 | - if ( $percentage > 100 ) { |
|
526 | + if ($percentage > 100) { |
|
527 | 527 | $percentage = 100; |
528 | 528 | } |
529 | 529 | |
@@ -545,23 +545,23 @@ discard block |
||
545 | 545 | $data = $this->get_data(); |
546 | 546 | $cols = $this->get_csv_cols(); |
547 | 547 | |
548 | - if ( $data ) { |
|
548 | + if ($data) { |
|
549 | 549 | |
550 | 550 | // Output each row |
551 | - foreach ( $data as $row ) { |
|
551 | + foreach ($data as $row) { |
|
552 | 552 | $i = 1; |
553 | - foreach ( $row as $col_id => $column ) { |
|
553 | + foreach ($row as $col_id => $column) { |
|
554 | 554 | // Make sure the column is valid |
555 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
556 | - $row_data .= '"' . preg_replace( '/"/', "'", $column ) . '"'; |
|
557 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
558 | - $i ++; |
|
555 | + if (array_key_exists($col_id, $cols)) { |
|
556 | + $row_data .= '"'.preg_replace('/"/', "'", $column).'"'; |
|
557 | + $row_data .= $i == count($cols) ? '' : ','; |
|
558 | + $i++; |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | $row_data .= "\r\n"; |
562 | 562 | } |
563 | 563 | |
564 | - $this->stash_step_data( $row_data ); |
|
564 | + $this->stash_step_data($row_data); |
|
565 | 565 | |
566 | 566 | return $row_data; |
567 | 567 | } |