PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.2.0
GiveWP – Donation Plugin and Fundraising Platform v2.2.0
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-forms.php 8 years ago class-batch-export.php 8 years ago class-core-settings-export.php 8 years ago class-export-earnings.php 8 years ago class-export.php 8 years ago class-give-export-donations.php 8 years ago export-actions.php 8 years ago export-functions.php 8 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
557 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 parse_str( $fields );
194
195 if ( ! empty( $give_forms_categories ) || ! empty( $give_forms_tags ) ) {
196 $args['posts_per_page'] = -1;
197 }
198
199 if ( ! empty( $give_forms_categories ) && ! empty( $give_forms_tags ) ) {
200 $args['tax_query']['relation'] = 'AND';
201 }
202
203 if ( ! empty( $give_forms_categories ) ) {
204 $args['tax_query'][] = array(
205 'taxonomy' => 'give_forms_category',
206 'field' => 'term_id',
207 'terms' => $give_forms_categories,
208 'operator' => 'AND',
209 );
210 }
211
212 if ( ! empty( $give_forms_tags ) ) {
213 $args['tax_query'][] = array(
214 'taxonomy' => 'give_forms_tag',
215 'field' => 'term_id',
216 'terms' => $give_forms_tags,
217 'operator' => 'AND',
218 );
219 }
220
221 return $args;
222 }
223
224 add_filter( 'give_ajax_form_search_args', 'give_export_donation_form_search_args' );
225
226 /**
227 * Add Donation standard fields in export donation page
228 *
229 * @since 2.1
230 */
231 function give_export_donation_standard_fields() {
232 ?>
233 <tr>
234 <td scope="row" class="row-title">
235 <label><?php _e( 'Standard Columns:', 'give' ); ?></label>
236 </td>
237 <td>
238 <div class="give-clearfix">
239 <ul class="give-export-option">
240 <li class="give-export-option-fields give-export-option-payment-fields">
241 <ul class="give-export-option-payment-fields-ul">
242
243 <li class="give-export-option-label give-export-option-donation-label">
244 <span>
245 <?php _e( 'Donation Payment Fields', 'give' ); ?>
246 </span>
247 </li>
248
249 <li class="give-export-option-start">
250 <label for="give-export-donation-id">
251 <input type="checkbox" checked
252 name="give_give_donations_export_option[donation_id]"
253 id="give-export-donation-id"><?php _e( 'Donation ID', 'give' ); ?>
254 </label>
255 </li>
256
257 <?php
258 if ( give_is_setting_enabled( give_get_option( 'sequential-ordering_status', 'disabled' ) ) ) {
259 ?>
260 <li>
261 <label for="give-export-seq-id">
262 <input type="checkbox" checked
263 name="give_give_donations_export_option[seq_id]"
264 id="give-export-seq-id"><?php _e( 'Donation Number', 'give' ); ?>
265 </label>
266 </li>
267 <?php
268 }
269 ?>
270
271 <li>
272 <label for="give-export-donation-sum">
273 <input type="checkbox" checked
274 name="give_give_donations_export_option[donation_total]"
275 id="give-export-donation-sum"><?php _e( 'Donation Total', 'give' ); ?>
276 </label>
277 </li>
278
279 <li>
280 <label for="give-export-donation-currency_code">
281 <input type="checkbox" checked
282 name="give_give_donations_export_option[currency_code]"
283 id="give-export-donation-currency_code"><?php _e( 'Currency Code', 'give' ); ?>
284 </label>
285 </li>
286
287 <li>
288 <label for="give-export-donation-currency_symbol">
289 <input type="checkbox" checked
290 name="give_give_donations_export_option[currency_symbol]"
291 id="give-export-donation-currency_symbol"><?php _e( 'Currency Symbol', 'give' ); ?>
292 </label>
293 </li>
294
295 <li>
296 <label for="give-export-donation-status">
297 <input type="checkbox" checked
298 name="give_give_donations_export_option[donation_status]"
299 id="give-export-donation-status"><?php _e( 'Donation Status', 'give' ); ?>
300 </label>
301 </li>
302
303 <li>
304 <label for="give-export-donation-date">
305 <input type="checkbox" checked
306 name="give_give_donations_export_option[donation_date]"
307 id="give-export-donation-date"><?php _e( 'Donation Date', 'give' ); ?>
308 </label>
309 </li>
310
311 <li>
312 <label for="give-export-donation-time">
313 <input type="checkbox" checked
314 name="give_give_donations_export_option[donation_time]"
315 id="give-export-donation-time"><?php _e( 'Donation Time', 'give' ); ?>
316 </label>
317 </li>
318
319 <li>
320 <label for="give-export-payment-gateway">
321 <input type="checkbox" checked
322 name="give_give_donations_export_option[payment_gateway]"
323 id="give-export-payment-gateway"><?php _e( 'Payment Gateway', 'give' ); ?>
324 </label>
325 </li>
326
327 <li>
328 <label for="give-export-payment-mode">
329 <input type="checkbox" checked
330 name="give_give_donations_export_option[payment_mode]"
331 id="give-export-payment-mode"><?php _e( 'Payment Mode', 'give' ); ?>
332 </label>
333 </li>
334
335 <?php
336 /*
337 * Action to add extra columns in standard payment fields
338 *
339 * @since 2.1
340 */
341 do_action( 'give_export_donation_standard_payment_fields' );
342 ?>
343 </ul>
344 </li>
345
346 <li class="give-export-option-fields give-export-option-form-fields">
347 <ul class="give-export-option-form-fields-ul">
348
349 <li class="give-export-option-label give-export-option-Form-label">
350 <span>
351 <?php _e( 'Donation Form Fields', 'give' ); ?>
352 </span>
353 </li>
354
355
356 <li class="give-export-option-start">
357 <label for="give-export-donation-form-id">
358 <input type="checkbox" checked
359 name="give_give_donations_export_option[form_id]"
360 id="give-export-donation-form-id"><?php _e( 'Donation Form ID', 'give' ); ?>
361 </label>
362 </li>
363
364 <li>
365 <label for="give-export-donation-form-title">
366 <input type="checkbox" checked
367 name="give_give_donations_export_option[form_title]"
368 id="give-export-donation-form-title"><?php _e( 'Donation Form Title', 'give' ); ?>
369 </label>
370 </li>
371
372 <li>
373 <label for="give-export-donation-form-level-id">
374 <input type="checkbox" checked
375 name="give_give_donations_export_option[form_level_id]"
376 id="give-export-donation-form-level-id"><?php _e( 'Donation Form Level ID', 'give' ); ?>
377 </label>
378 </li>
379
380 <li>
381 <label for="give-export-donation-form-level-title">
382 <input type="checkbox" checked
383 name="give_give_donations_export_option[form_level_title]"
384 id="give-export-donation-form-level-title"><?php _e( 'Donation Form Level Title', 'give' ); ?>
385 </label>
386 </li>
387
388 <?php
389 /*
390 * Action to add extra columns in standard form fields
391 *
392 * @since 2.1
393 */
394 do_action( 'give_export_donation_standard_form_fields' );
395 ?>
396 </ul>
397 </li>
398
399 <li class="give-export-option-fields give-export-option-donor-fields">
400 <ul class="give-export-option-donor-fields-ul">
401
402 <li class="give-export-option-label give-export-option-donor-label">
403 <span>
404 <?php _e( 'Donor Fields', 'give' ); ?>
405 </span>
406 </li>
407
408 <li class="give-export-option-start">
409 <label for="give-export-title-prefix">
410 <input type="checkbox" checked
411 name="give_give_donations_export_option[title_prefix]"
412 id="give-export-title-prefix"><?php esc_html_e( 'Donor\'s Title Prefix', 'give' ); ?>
413 </label>
414 </li>
415
416 <li class="give-export-option-start">
417 <label for="give-export-first-name">
418 <input type="checkbox" checked
419 name="give_give_donations_export_option[first_name]"
420 id="give-export-first-name"><?php _e( 'Donor\'s First Name', 'give' ); ?>
421 </label>
422 </li>
423
424 <li>
425 <label for="give-export-last-name">
426 <input type="checkbox" checked
427 name="give_give_donations_export_option[last_name]"
428 id="give-export-last-name"><?php _e( 'Donor\'s Last Name', 'give' ); ?>
429 </label>
430 </li>
431
432 <li>
433 <label for="give-export-email">
434 <input type="checkbox" checked
435 name="give_give_donations_export_option[email]"
436 id="give-export-email"><?php _e( 'Donor\'s Email', 'give' ); ?>
437 </label>
438 </li>
439
440 <li>
441 <label for="give-export-company">
442 <input type="checkbox" checked
443 name="give_give_donations_export_option[company]"
444 id="give-export-company"><?php _e( 'Company Name', 'give' ); ?>
445 </label>
446 </li>
447
448 <li>
449 <label for="give-export-address">
450 <input type="checkbox" checked
451 name="give_give_donations_export_option[address]"
452 id="give-export-address"><?php _e( 'Donor\'s Billing Address', 'give' ); ?>
453 </label>
454 </li>
455
456 <li>
457 <label for="give-export-userid">
458 <input type="checkbox" checked
459 name="give_give_donations_export_option[userid]"
460 id="give-export-userid"><?php _e( 'User ID', 'give' ); ?>
461 </label>
462 </li>
463
464 <li>
465 <label for="give-export-donorid">
466 <input type="checkbox" checked
467 name="give_give_donations_export_option[donorid]"
468 id="give-export-donorid"><?php _e( 'Donor ID', 'give' ); ?>
469 </label>
470 </li>
471
472 <li>
473 <label for="give-export-donor-ip">
474 <input type="checkbox" checked
475 name="give_give_donations_export_option[donor_ip]"
476 id="give-export-donor-ip"><?php _e( 'Donor IP Address', 'give' ); ?>
477 </label>
478 </li>
479
480 <?php
481 /*
482 * Action to add extra columns in standard donor fields
483 *
484 * @since 2.1
485 */
486 do_action( 'give_export_donation_standard_donor_fields' );
487 ?>
488 </ul>
489 </li>
490
491 <?php
492 /**
493 * Action to add custom export column.
494 *
495 * @since 2.1.4
496 */
497 do_action( 'give_export_donation_add_custom_column' );
498 ?>
499 </ul>
500 </div>
501 </td>
502 </tr>
503 <?php
504 }
505
506 add_action( 'give_export_donation_fields', 'give_export_donation_standard_fields', 10 );
507
508 /**
509 * Add Donation Custom fields in export donation page
510 *
511 * @since 2.1
512 */
513 function give_export_donation_custom_fields() {
514 ?>
515 <tr
516 class="give-hidden give-export-donations-hide give-export-donations-standard-fields">
517 <td scope="row" class="row-title">
518 <label><?php _e( 'Custom Field Columns:', 'give' ); ?></label>
519 </td>
520 <td class="give-field-wrap">
521 <div class="give-clearfix">
522 <ul class="give-export-option-ul"></ul>
523 <p class="give-field-description"><?php _e( 'The following fields may have been created by custom code, or another plugin.', 'give' ); ?></p>
524 </div>
525 </td>
526 </tr>
527 <?php
528 }
529
530 add_action( 'give_export_donation_fields', 'give_export_donation_custom_fields', 30 );
531
532
533 /**
534 * Add Donation hidden fields in export donation page
535 *
536 * @since 2.1
537 */
538 function give_export_donation_hidden_fields() {
539 ?>
540
541 <tr class="give-hidden give-export-donations-hide give-export-donations-hidden-fields">
542 <td scope="row" class="row-title">
543 <label><?php _e( 'Hidden Custom Field Columns:', 'give' ); ?></label>
544 </td>
545 <td class="give-field-wrap">
546 <div class="give-clearfix">
547 <ul class="give-export-option-ul"></ul>
548 <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>
549 </div>
550 </td>
551 </tr>
552 <?php
553 }
554
555 add_action( 'give_export_donation_fields', 'give_export_donation_hidden_fields', 40 );
556
557