PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.4.5
GiveWP – Donation Plugin and Fundraising Platform v2.4.5
4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / tools / export / give-export-donations-functions.php
give / includes / admin / tools / export Last commit date
class-batch-export-donors.php 7 years ago class-batch-export.php 7 years ago class-core-settings-export.php 7 years ago class-export-earnings.php 7 years ago class-export.php 7 years ago class-give-export-donations.php 7 years ago export-actions.php 7 years ago export-functions.php 7 years ago give-export-donations-exporter.php 7 years ago give-export-donations-functions.php 7 years ago pdf-reports.php 7 years ago
give-export-donations-functions.php
568 lines
1 <?php
2 /**
3 * Give Export Donations Functions
4 */
5
6
7 /**
8 * AJAX
9 *
10 * @see http://wordpress.stackexchange.com/questions/58834/echo-all-meta-keys-of-a-custom-post-type
11 *
12 * @return string
13 */
14 function give_export_donations_get_custom_fields() {
15
16 global $wpdb;
17 $post_type = 'give_payment';
18 $responses = array();
19 $donationmeta_table_key = Give()->payment_meta->get_meta_type() . '_id';
20
21 $form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : '';
22
23 if ( empty( $form_id ) ) {
24 return false;
25 }
26
27 $args = array(
28 'give_forms' => array( $form_id ),
29 'posts_per_page' => - 1,
30 'fields' => 'ids',
31 );
32 $donation_list = implode( ',', (array) give_get_payments( $args ) );
33
34 $query_and = sprintf(
35 "AND $wpdb->posts.ID IN (%s)
36 AND $wpdb->donationmeta.meta_key != ''
37 AND $wpdb->donationmeta.meta_key NOT RegExp '(^[_0-9].+$)'",
38 $donation_list
39 );
40
41 $query = "
42 SELECT DISTINCT($wpdb->donationmeta.meta_key)
43 FROM $wpdb->posts
44 LEFT JOIN $wpdb->donationmeta
45 ON $wpdb->posts.ID = {$wpdb->donationmeta}.{$donationmeta_table_key}
46 WHERE $wpdb->posts.post_type = '%s'
47 " . $query_and;
48
49 $meta_keys = $wpdb->get_col( $wpdb->prepare( $query, $post_type ) );
50
51 if ( ! empty( $meta_keys ) ) {
52 $responses['standard_fields'] = array_values( $meta_keys );
53 }
54
55 $query_and = sprintf(
56 "AND $wpdb->posts.ID IN (%s)
57 AND $wpdb->donationmeta.meta_key != ''
58 AND $wpdb->donationmeta.meta_key NOT RegExp '^[^_]'",
59 $donation_list
60 );
61
62 $query = "
63 SELECT DISTINCT($wpdb->donationmeta.meta_key)
64 FROM $wpdb->posts
65 LEFT JOIN $wpdb->donationmeta
66 ON $wpdb->posts.ID = {$wpdb->donationmeta}.{$donationmeta_table_key}
67 WHERE $wpdb->posts.post_type = '%s'
68 " . $query_and;
69
70 $hidden_meta_keys = $wpdb->get_col( $wpdb->prepare( $query, $post_type ) );
71
72 /**
73 * Filter to modify hidden keys that are going to be ignore when displaying the hidden keys
74 *
75 * @since 2.1
76 *
77 * @param array $ignore_hidden_keys Hidden keys that are going to be ignore
78 * @param array $form_id Donation form id
79 *
80 * @return array $ignore_hidden_keys Hidden keys that are going to be ignore
81 */
82 $ignore_hidden_keys = apply_filters( 'give_export_donations_ignore_hidden_keys', array(
83 '_give_payment_meta',
84 '_give_payment_gateway',
85 '_give_payment_mode',
86 '_give_payment_form_title',
87 '_give_payment_form_id',
88 '_give_payment_price_id',
89 '_give_payment_user_id',
90 '_give_payment_user_email',
91 '_give_payment_user_ip',
92 '_give_payment_customer_id',
93 '_give_payment_total',
94 '_give_completed_date',
95 '_give_donation_company',
96 '_give_donor_billing_first_name',
97 '_give_donor_billing_last_name',
98 '_give_payment_donor_email',
99 '_give_payment_donor_id',
100 '_give_payment_date',
101 '_give_donor_billing_address1',
102 '_give_donor_billing_address2',
103 '_give_donor_billing_city',
104 '_give_donor_billing_zip',
105 '_give_donor_billing_state',
106 '_give_donor_billing_country',
107 '_give_payment_import',
108 '_give_payment_currency',
109 '_give_payment_import_id',
110 '_give_payment_donor_ip',
111 '_give_payment_donor_title_prefix',
112 ),
113 $form_id
114 );
115
116 // Unset ignored hidden keys.
117 foreach ( $ignore_hidden_keys as $key ) {
118 if ( ( $key = array_search( $key, $hidden_meta_keys ) ) !== false ) {
119 unset( $hidden_meta_keys[ $key ] );
120 }
121 }
122
123 if ( ! empty( $hidden_meta_keys ) ) {
124 $responses['hidden_fields'] = array_values( $hidden_meta_keys );
125 }
126
127 /**
128 * Filter to modify custom fields when select donation forms,
129 *
130 * @since 2.1
131 *
132 * @param array $responses Contain all the fields that need to be display when donation form is display
133 * @param int $form_id Donation Form ID
134 *
135 * @return array $responses
136 */
137 wp_send_json( (array) apply_filters( 'give_export_donations_get_custom_fields', $responses, $form_id ) );
138
139 }
140
141 add_action( 'wp_ajax_give_export_donations_get_custom_fields', 'give_export_donations_get_custom_fields' );
142
143 /**
144 * Register the payments batch exporter
145 *
146 * @since 1.0
147 */
148 function give_register_export_donations_batch_export() {
149 add_action( 'give_batch_export_class_include', 'give_export_donations_include_export_class', 10, 1 );
150 }
151
152 add_action( 'give_register_batch_exporter', 'give_register_export_donations_batch_export', 10 );
153
154
155 /**
156 * Includes the Give Export Donations Custom Exporter Class.
157 *
158 * @param $class Give_Export_Donations_CSV
159 */
160 function give_export_donations_include_export_class( $class ) {
161 if ( 'Give_Export_Donations_CSV' === $class ) {
162 require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/give-export-donations-exporter.php';
163 }
164 }
165
166
167 /**
168 * Create column key.
169 *
170 * @param $string
171 *
172 * @return string
173 */
174 function give_export_donations_create_column_key( $string ) {
175 return sanitize_key( str_replace( ' ', '_', $string ) );
176 }
177
178 /**
179 * Filter to modify donation search form when search through AJAX
180 *
181 * @since 2.1
182 *
183 * @param $args
184 *
185 * @return array
186 */
187 function give_export_donation_form_search_args( $args ) {
188 if ( empty( $_POST['fields'] ) ) {
189 return $args;
190 }
191
192 $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null;
193
194 // Using parse_str() function without the result parameter is highly DISCOURAGED and DEPRECATED as of PHP 7.2.
195 $fields_result_array = array();
196 parse_str( $fields, $fields_result_array );
197
198 if ( ! empty( $give_forms_categories ) || ! empty( $give_forms_tags ) ) {
199 $args['posts_per_page'] = - 1;
200 }
201
202 if ( ! empty( $give_forms_categories ) && ! empty( $give_forms_tags ) ) {
203 $args['tax_query']['relation'] = 'AND';
204 }
205
206 if ( ! empty( $give_forms_categories ) ) {
207 $args['tax_query'][] = array(
208 'taxonomy' => 'give_forms_category',
209 'field' => 'term_id',
210 'terms' => $give_forms_categories,
211 'operator' => 'AND',
212 );
213 }
214
215 if ( ! empty( $give_forms_tags ) ) {
216 $args['tax_query'][] = array(
217 'taxonomy' => 'give_forms_tag',
218 'field' => 'term_id',
219 'terms' => $give_forms_tags,
220 'operator' => 'AND',
221 );
222 }
223
224 return $args;
225 }
226
227 add_filter( 'give_ajax_form_search_args', 'give_export_donation_form_search_args' );
228
229 /**
230 * Add Donation standard fields in export donation page
231 *
232 * @since 2.1
233 */
234 function give_export_donation_standard_fields() {
235 ?>
236 <tr>
237 <td scope="row" class="row-title">
238 <label><?php _e( 'Standard Columns:', 'give' ); ?></label>
239 </td>
240 <td>
241 <div class="give-clearfix">
242 <ul class="give-export-option">
243 <li class="give-export-option-fields give-export-option-payment-fields">
244 <ul class="give-export-option-payment-fields-ul">
245
246 <li class="give-export-option-label give-export-option-donation-label">
247 <span>
248 <?php _e( 'Donation Payment Fields', 'give' ); ?>
249 </span>
250 </li>
251
252 <li class="give-export-option-start">
253 <label for="give-export-donation-id">
254 <input type="checkbox" checked
255 name="give_give_donations_export_option[donation_id]"
256 id="give-export-donation-id"><?php _e( 'Donation ID', 'give' ); ?>
257 </label>
258 </li>
259
260 <?php
261 if ( give_is_setting_enabled( give_get_option( 'sequential-ordering_status', 'disabled' ) ) ) {
262 ?>
263 <li>
264 <label for="give-export-seq-id">
265 <input type="checkbox" checked
266 name="give_give_donations_export_option[seq_id]"
267 id="give-export-seq-id"><?php _e( 'Donation Number', 'give' ); ?>
268 </label>
269 </li>
270 <?php
271 }
272 ?>
273
274 <li>
275 <label for="give-export-donation-sum">
276 <input type="checkbox" checked
277 name="give_give_donations_export_option[donation_total]"
278 id="give-export-donation-sum"><?php _e( 'Donation Total', 'give' ); ?>
279 </label>
280 </li>
281
282 <li>
283 <label for="give-export-donation-currency_code">
284 <input type="checkbox" checked
285 name="give_give_donations_export_option[currency_code]"
286 id="give-export-donation-currency_code"><?php _e( 'Currency Code', 'give' ); ?>
287 </label>
288 </li>
289
290 <li>
291 <label for="give-export-donation-currency_symbol">
292 <input type="checkbox" checked
293 name="give_give_donations_export_option[currency_symbol]"
294 id="give-export-donation-currency_symbol"><?php _e( 'Currency Symbol', 'give' ); ?>
295 </label>
296 </li>
297
298 <li>
299 <label for="give-export-donation-status">
300 <input type="checkbox" checked
301 name="give_give_donations_export_option[donation_status]"
302 id="give-export-donation-status"><?php _e( 'Donation Status', 'give' ); ?>
303 </label>
304 </li>
305
306 <li>
307 <label for="give-export-donation-date">
308 <input type="checkbox" checked
309 name="give_give_donations_export_option[donation_date]"
310 id="give-export-donation-date"><?php _e( 'Donation Date', 'give' ); ?>
311 </label>
312 </li>
313
314 <li>
315 <label for="give-export-donation-time">
316 <input type="checkbox" checked
317 name="give_give_donations_export_option[donation_time]"
318 id="give-export-donation-time"><?php _e( 'Donation Time', 'give' ); ?>
319 </label>
320 </li>
321
322 <li>
323 <label for="give-export-payment-gateway">
324 <input type="checkbox" checked
325 name="give_give_donations_export_option[payment_gateway]"
326 id="give-export-payment-gateway"><?php _e( 'Payment Gateway', 'give' ); ?>
327 </label>
328 </li>
329
330 <li>
331 <label for="give-export-payment-mode">
332 <input type="checkbox" checked
333 name="give_give_donations_export_option[payment_mode]"
334 id="give-export-payment-mode"><?php _e( 'Payment Mode', 'give' ); ?>
335 </label>
336 </li>
337
338 <?php
339 /*
340 * Action to add extra columns in standard payment fields
341 *
342 * @since 2.1
343 */
344 do_action( 'give_export_donation_standard_payment_fields' );
345 ?>
346 </ul>
347 </li>
348
349 <li class="give-export-option-fields give-export-option-form-fields">
350 <ul class="give-export-option-form-fields-ul">
351
352 <li class="give-export-option-label give-export-option-Form-label">
353 <span>
354 <?php _e( 'Donation Form Fields', 'give' ); ?>
355 </span>
356 </li>
357
358
359 <li class="give-export-option-start">
360 <label for="give-export-donation-form-id">
361 <input type="checkbox" checked
362 name="give_give_donations_export_option[form_id]"
363 id="give-export-donation-form-id"><?php _e( 'Donation Form ID', 'give' ); ?>
364 </label>
365 </li>
366
367 <li>
368 <label for="give-export-donation-form-title">
369 <input type="checkbox" checked
370 name="give_give_donations_export_option[form_title]"
371 id="give-export-donation-form-title"><?php _e( 'Donation Form Title', 'give' ); ?>
372 </label>
373 </li>
374
375 <li>
376 <label for="give-export-donation-form-level-id">
377 <input type="checkbox" checked
378 name="give_give_donations_export_option[form_level_id]"
379 id="give-export-donation-form-level-id"><?php _e( 'Donation Form Level ID', 'give' ); ?>
380 </label>
381 </li>
382
383 <li>
384 <label for="give-export-donation-form-level-title">
385 <input type="checkbox" checked
386 name="give_give_donations_export_option[form_level_title]"
387 id="give-export-donation-form-level-title"><?php _e( 'Donation Form Level Title', 'give' ); ?>
388 </label>
389 </li>
390
391 <?php
392 /*
393 * Action to add extra columns in standard form fields
394 *
395 * @since 2.1
396 */
397 do_action( 'give_export_donation_standard_form_fields' );
398 ?>
399 </ul>
400 </li>
401
402 <li class="give-export-option-fields give-export-option-donor-fields">
403 <ul class="give-export-option-donor-fields-ul">
404
405 <li class="give-export-option-label give-export-option-donor-label">
406 <span>
407 <?php _e( 'Donor Fields', 'give' ); ?>
408 </span>
409 </li>
410
411 <li class="give-export-option-start">
412 <label for="give-export-title-prefix">
413 <input type="checkbox" checked
414 name="give_give_donations_export_option[title_prefix]"
415 id="give-export-title-prefix"><?php esc_html_e( 'Donor\'s Title Prefix', 'give' ); ?>
416 </label>
417 </li>
418
419 <li class="give-export-option-start">
420 <label for="give-export-first-name">
421 <input type="checkbox" checked
422 name="give_give_donations_export_option[first_name]"
423 id="give-export-first-name"><?php _e( 'Donor\'s First Name', 'give' ); ?>
424 </label>
425 </li>
426
427 <li>
428 <label for="give-export-last-name">
429 <input type="checkbox" checked
430 name="give_give_donations_export_option[last_name]"
431 id="give-export-last-name"><?php _e( 'Donor\'s Last Name', 'give' ); ?>
432 </label>
433 </li>
434
435 <li>
436 <label for="give-export-email">
437 <input type="checkbox" checked
438 name="give_give_donations_export_option[email]"
439 id="give-export-email"><?php _e( 'Donor\'s Email', 'give' ); ?>
440 </label>
441 </li>
442
443 <li>
444 <label for="give-export-company">
445 <input type="checkbox" checked
446 name="give_give_donations_export_option[company]"
447 id="give-export-company"><?php _e( 'Company Name', 'give' ); ?>
448 </label>
449 </li>
450
451 <li>
452 <label for="give-export-address">
453 <input type="checkbox" checked
454 name="give_give_donations_export_option[address]"
455 id="give-export-address"><?php _e( 'Donor\'s Billing Address', 'give' ); ?>
456 </label>
457 </li>
458
459 <li>
460 <label for="give-export-comment">
461 <input type="checkbox" checked
462 name="give_give_donations_export_option[comment]"
463 id="give-export-comment"><?php _e( 'Donor\'s Comment', 'give' ); ?>
464 </label>
465 </li>
466
467 <li>
468 <label for="give-export-userid">
469 <input type="checkbox" checked
470 name="give_give_donations_export_option[userid]"
471 id="give-export-userid"><?php _e( 'User ID', 'give' ); ?>
472 </label>
473 </li>
474
475 <li>
476 <label for="give-export-donorid">
477 <input type="checkbox" checked
478 name="give_give_donations_export_option[donorid]"
479 id="give-export-donorid"><?php _e( 'Donor ID', 'give' ); ?>
480 </label>
481 </li>
482
483 <li>
484 <label for="give-export-donor-ip">
485 <input type="checkbox" checked
486 name="give_give_donations_export_option[donor_ip]"
487 id="give-export-donor-ip"><?php _e( 'Donor IP Address', 'give' ); ?>
488 </label>
489 </li>
490
491 <?php
492 /*
493 * Action to add extra columns in standard donor fields
494 *
495 * @since 2.1
496 */
497 do_action( 'give_export_donation_standard_donor_fields' );
498 ?>
499 </ul>
500 </li>
501
502 <?php
503 /**
504 * Action to add custom export column.
505 *
506 * @since 2.1.4
507 */
508 do_action( 'give_export_donation_add_custom_column' );
509 ?>
510 </ul>
511 </div>
512 </td>
513 </tr>
514 <?php
515 }
516
517 add_action( 'give_export_donation_fields', 'give_export_donation_standard_fields', 10 );
518
519 /**
520 * Add Donation Custom fields in export donation page
521 *
522 * @since 2.1
523 */
524 function give_export_donation_custom_fields() {
525 ?>
526 <tr
527 class="give-hidden give-export-donations-hide give-export-donations-standard-fields">
528 <td scope="row" class="row-title">
529 <label><?php _e( 'Custom Field Columns:', 'give' ); ?></label>
530 </td>
531 <td class="give-field-wrap">
532 <div class="give-clearfix">
533 <ul class="give-export-option-ul"></ul>
534 <p class="give-field-description"><?php _e( 'The following fields may have been created by custom code, or another plugin.', 'give' ); ?></p>
535 </div>
536 </td>
537 </tr>
538 <?php
539 }
540
541 add_action( 'give_export_donation_fields', 'give_export_donation_custom_fields', 30 );
542
543
544 /**
545 * Add Donation hidden fields in export donation page
546 *
547 * @since 2.1
548 */
549 function give_export_donation_hidden_fields() {
550 ?>
551
552 <tr class="give-hidden give-export-donations-hide give-export-donations-hidden-fields">
553 <td scope="row" class="row-title">
554 <label><?php _e( 'Hidden Custom Field Columns:', 'give' ); ?></label>
555 </td>
556 <td class="give-field-wrap">
557 <div class="give-clearfix">
558 <ul class="give-export-option-ul"></ul>
559 <p class="give-field-description"><?php _e( 'The following hidden custom fields contain data created by Give Core, a Give Add-on, another plugin, etc.<br/>Hidden fields are generally used for programming logic, but you may contain data you would like to export.', 'give' ); ?></p>
560 </div>
561 </td>
562 </tr>
563 <?php
564 }
565
566 add_action( 'give_export_donation_fields', 'give_export_donation_hidden_fields', 40 );
567
568