PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.1.4
GiveWP – Donation Plugin and Fundraising Platform v2.1.4
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 8 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 8 years ago give-export-donations-functions.php 8 years ago pdf-reports.php 8 years ago
give-export-donations-functions.php
534 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
20 $form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : '';
21
22 if ( empty( $form_id ) ) {
23 return false;
24 }
25
26 $args = array(
27 'give_forms' => array( $form_id ),
28 'posts_per_page' => - 1,
29 'fields' => 'ids',
30 );
31 $donation_list = implode( ',', (array) give_get_payments( $args ) );
32
33 $query_and = sprintf(
34 "AND $wpdb->posts.ID IN (%s)
35 AND $wpdb->paymentmeta.meta_key != ''
36 AND $wpdb->paymentmeta.meta_key NOT RegExp '(^[_0-9].+$)'",
37 $donation_list
38 );
39
40 $query = "
41 SELECT DISTINCT($wpdb->paymentmeta.meta_key)
42 FROM $wpdb->posts
43 LEFT JOIN $wpdb->paymentmeta
44 ON $wpdb->posts.ID = $wpdb->paymentmeta.payment_id
45 WHERE $wpdb->posts.post_type = '%s'
46 " . $query_and;
47
48 $meta_keys = $wpdb->get_col( $wpdb->prepare( $query, $post_type ) );
49
50 if ( ! empty( $meta_keys ) ) {
51 $responses['standard_fields'] = array_values( $meta_keys );
52 }
53
54 $query_and = sprintf(
55 "AND $wpdb->posts.ID IN (%s)
56 AND $wpdb->paymentmeta.meta_key != ''
57 AND $wpdb->paymentmeta.meta_key NOT RegExp '^[^_]'",
58 $donation_list
59 );
60
61 $query = "
62 SELECT DISTINCT($wpdb->paymentmeta.meta_key)
63 FROM $wpdb->posts
64 LEFT JOIN $wpdb->paymentmeta
65 ON $wpdb->posts.ID = $wpdb->paymentmeta.payment_id
66 WHERE $wpdb->posts.post_type = '%s'
67 " . $query_and;
68
69 $hidden_meta_keys = $wpdb->get_col( $wpdb->prepare( $query, $post_type ) );
70
71 /**
72 * Filter to modify hidden keys that are going to be ignore when displaying the hidden keys
73 *
74 * @since 2.1
75 *
76 * @param array $ignore_hidden_keys Hidden keys that are going to be ignore
77 * @param array $form_id Donation form id
78 *
79 * @return array $ignore_hidden_keys Hidden keys that are going to be ignore
80 */
81 $ignore_hidden_keys = apply_filters( 'give_export_donations_ignore_hidden_keys', array(
82 '_give_payment_meta',
83 '_give_payment_gateway',
84 '_give_payment_form_title',
85 '_give_payment_form_id',
86 '_give_payment_price_id',
87 '_give_payment_user_id',
88 '_give_payment_user_email',
89 '_give_payment_user_ip',
90 '_give_payment_customer_id',
91 '_give_payment_total',
92 '_give_completed_date',
93 '_give_donation_company',
94 '_give_donor_billing_first_name',
95 '_give_donor_billing_last_name',
96 '_give_payment_donor_email',
97 '_give_payment_donor_id',
98 '_give_payment_date',
99 '_give_donor_billing_address1',
100 '_give_donor_billing_address2',
101 '_give_donor_billing_city',
102 '_give_donor_billing_zip',
103 '_give_donor_billing_state',
104 '_give_donor_billing_country',
105 '_give_payment_import',
106 '_give_payment_currency',
107 '_give_payment_import_id',
108 '_give_payment_donor_ip',
109 ),
110 $form_id
111 );
112
113 // Unset ignored hidden keys.
114 foreach ( $ignore_hidden_keys as $key ) {
115 if ( ( $key = array_search( $key, $hidden_meta_keys ) ) !== false ) {
116 unset( $hidden_meta_keys[ $key ] );
117 }
118 }
119
120 if ( ! empty( $hidden_meta_keys ) ) {
121 $responses['hidden_fields'] = array_values( $hidden_meta_keys );
122 }
123
124 /**
125 * Filter to modify custom fields when select donation forms,
126 *
127 * @since 2.1
128 *
129 * @param array $responses Contain all the fields that need to be display when donation form is display
130 * @param int $form_id Donation Form ID
131 *
132 * @return array $responses
133 */
134 wp_send_json( (array) apply_filters( 'give_export_donations_get_custom_fields', $responses, $form_id ) );
135
136 }
137
138 add_action( 'wp_ajax_give_export_donations_get_custom_fields', 'give_export_donations_get_custom_fields' );
139
140 /**
141 * Register the payments batch exporter
142 *
143 * @since 1.0
144 */
145 function give_register_export_donations_batch_export() {
146 add_action( 'give_batch_export_class_include', 'give_export_donations_include_export_class', 10, 1 );
147 }
148
149 add_action( 'give_register_batch_exporter', 'give_register_export_donations_batch_export', 10 );
150
151
152 /**
153 * Includes the Give Export Donations Custom Exporter Class.
154 *
155 * @param $class Give_Export_Donations_CSV
156 */
157 function give_export_donations_include_export_class( $class ) {
158 if ( 'Give_Export_Donations_CSV' === $class ) {
159 require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/give-export-donations-exporter.php';
160 }
161 }
162
163
164 /**
165 * Create column key.
166 *
167 * @param $string
168 *
169 * @return string
170 */
171 function give_export_donations_create_column_key( $string ) {
172 return sanitize_key( str_replace( ' ', '_', $string ) );
173 }
174
175 /**
176 * Filter to modify donation search form when search through AJAX
177 *
178 * @since 2.1
179 *
180 * @param $args
181 *
182 * @return array
183 */
184 function give_export_donation_form_search_args( $args ) {
185 if ( empty( $_POST['fields'] ) ) {
186 return $args;
187 }
188
189 $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null;
190 parse_str( $fields );
191
192 if ( ! empty( $give_forms_categories ) && ! empty( $give_forms_tags ) ) {
193 $args['tax_query']['relation'] = 'AND';
194 }
195
196 if ( ! empty( $give_forms_categories ) ) {
197 $args['tax_query'][] = array(
198 'taxonomy' => 'give_forms_category',
199 'field' => 'term_id',
200 'terms' => $give_forms_categories,
201 'operator' => 'AND',
202 );
203 }
204
205 if ( ! empty( $give_forms_tags ) ) {
206 $args['tax_query'][] = array(
207 'taxonomy' => 'give_forms_tag',
208 'field' => 'term_id',
209 'terms' => $give_forms_tags,
210 'operator' => 'AND',
211 );
212 }
213
214 return $args;
215 }
216
217 add_filter( 'give_ajax_form_search_args', 'give_export_donation_form_search_args' );
218
219 /**
220 * Add Donation standard fields in export donation page
221 *
222 * @since 2.1
223 */
224 function give_export_donation_standard_fields() {
225 ?>
226 <tr>
227 <td scope="row" class="row-title">
228 <label><?php _e( 'Standard Columns:', 'give' ); ?></label>
229 </td>
230 <td>
231 <div class="give-clearfix">
232 <ul class="give-export-option">
233 <li class="give-export-option-fields give-export-option-payment-fields">
234 <ul class="give-export-option-payment-fields-ul">
235
236 <li class="give-export-option-label give-export-option-donation-label">
237 <span>
238 <?php _e( 'Donation Payment Fields', 'give' ); ?>
239 </span>
240 </li>
241
242 <li class="give-export-option-start">
243 <label for="give-export-donation-id">
244 <input type="checkbox" checked
245 name="give_give_donations_export_option[donation_id]"
246 id="give-export-donation-id"><?php _e( 'Donation ID', 'give' ); ?>
247 </label>
248 </li>
249
250 <?php
251 if ( give_is_setting_enabled( give_get_option( 'sequential-ordering_status', 'disabled' ) ) ) {
252 ?>
253 <li>
254 <label for="give-export-seq-id">
255 <input type="checkbox" checked
256 name="give_give_donations_export_option[seq_id]"
257 id="give-export-seq-id"><?php _e( 'Donation Number', 'give' ); ?>
258 </label>
259 </li>
260 <?php
261 }
262 ?>
263
264 <li>
265 <label for="give-export-donation-sum">
266 <input type="checkbox" checked
267 name="give_give_donations_export_option[donation_total]"
268 id="give-export-donation-sum"><?php _e( 'Donation Total', 'give' ); ?>
269 </label>
270 </li>
271
272 <li>
273 <label for="give-export-donation-currency_code">
274 <input type="checkbox" checked
275 name="give_give_donations_export_option[currency_code]"
276 id="give-export-donation-currency_code"><?php _e( 'Currency Code', 'give' ); ?>
277 </label>
278 </li>
279
280 <li>
281 <label for="give-export-donation-currency_symbol">
282 <input type="checkbox" checked
283 name="give_give_donations_export_option[currency_symbol]"
284 id="give-export-donation-currency_symbol"><?php _e( 'Currency Symbol', 'give' ); ?>
285 </label>
286 </li>
287
288 <li>
289 <label for="give-export-donation-status">
290 <input type="checkbox" checked
291 name="give_give_donations_export_option[donation_status]"
292 id="give-export-donation-status"><?php _e( 'Donation Status', 'give' ); ?>
293 </label>
294 </li>
295
296 <li>
297 <label for="give-export-donation-date">
298 <input type="checkbox" checked
299 name="give_give_donations_export_option[donation_date]"
300 id="give-export-donation-date"><?php _e( 'Donation Date', 'give' ); ?>
301 </label>
302 </li>
303
304 <li>
305 <label for="give-export-donation-time">
306 <input type="checkbox" checked
307 name="give_give_donations_export_option[donation_time]"
308 id="give-export-donation-time"><?php _e( 'Donation Time', 'give' ); ?>
309 </label>
310 </li>
311
312 <li>
313 <label for="give-export-payment-gateway">
314 <input type="checkbox" checked
315 name="give_give_donations_export_option[payment_gateway]"
316 id="give-export-payment-gateway"><?php _e( 'Payment Gateway', 'give' ); ?>
317 </label>
318 </li>
319
320 <?php
321 /*
322 * Action to add extra columns in standard payment fields
323 *
324 * @since 2.1
325 */
326 do_action( 'give_export_donation_standard_payment_fields' );
327 ?>
328 </ul>
329 </li>
330
331 <li class="give-export-option-fields give-export-option-form-fields">
332 <ul class="give-export-option-form-fields-ul">
333
334 <li class="give-export-option-label give-export-option-Form-label">
335 <span>
336 <?php _e( 'Donation Form Fields', 'give' ); ?>
337 </span>
338 </li>
339
340
341 <li class="give-export-option-start">
342 <label for="give-export-donation-form-id">
343 <input type="checkbox" checked
344 name="give_give_donations_export_option[form_id]"
345 id="give-export-donation-form-id"><?php _e( 'Donation Form ID', 'give' ); ?>
346 </label>
347 </li>
348
349 <li>
350 <label for="give-export-donation-form-title">
351 <input type="checkbox" checked
352 name="give_give_donations_export_option[form_title]"
353 id="give-export-donation-form-title"><?php _e( 'Donation Form Title', 'give' ); ?>
354 </label>
355 </li>
356
357 <li>
358 <label for="give-export-donation-form-level-id">
359 <input type="checkbox" checked
360 name="give_give_donations_export_option[form_level_id]"
361 id="give-export-donation-form-level-id"><?php _e( 'Donation Form Level ID', 'give' ); ?>
362 </label>
363 </li>
364
365 <li>
366 <label for="give-export-donation-form-level-title">
367 <input type="checkbox" checked
368 name="give_give_donations_export_option[form_level_title]"
369 id="give-export-donation-form-level-title"><?php _e( 'Donation Form Level Title', 'give' ); ?>
370 </label>
371 </li>
372
373 <?php
374 /*
375 * Action to add extra columns in standard form fields
376 *
377 * @since 2.1
378 */
379 do_action( 'give_export_donation_standard_form_fields' );
380 ?>
381 </ul>
382 </li>
383
384 <li class="give-export-option-fields give-export-option-donor-fields">
385 <ul class="give-export-option-donor-fields-ul">
386
387 <li class="give-export-option-label give-export-option-donor-label">
388 <span>
389 <?php _e( 'Donor Fields', 'give' ); ?>
390 </span>
391 </li>
392
393 <li class="give-export-option-start">
394 <label for="give-export-first-name">
395 <input type="checkbox" checked
396 name="give_give_donations_export_option[first_name]"
397 id="give-export-first-name"><?php _e( 'Donor\'s First Name', 'give' ); ?>
398 </label>
399 </li>
400
401 <li>
402 <label for="give-export-last-name">
403 <input type="checkbox" checked
404 name="give_give_donations_export_option[last_name]"
405 id="give-export-last-name"><?php _e( 'Donor\'s Last Name', 'give' ); ?>
406 </label>
407 </li>
408
409 <li>
410 <label for="give-export-email">
411 <input type="checkbox" checked
412 name="give_give_donations_export_option[email]"
413 id="give-export-email"><?php _e( 'Donor\'s Email', 'give' ); ?>
414 </label>
415 </li>
416
417 <li>
418 <label for="give-export-company">
419 <input type="checkbox" checked
420 name="give_give_donations_export_option[company]"
421 id="give-export-company"><?php _e( 'Company Name', 'give' ); ?>
422 </label>
423 </li>
424
425 <li>
426 <label for="give-export-address">
427 <input type="checkbox" checked
428 name="give_give_donations_export_option[address]"
429 id="give-export-address"><?php _e( 'Donor\'s Billing Address', 'give' ); ?>
430 </label>
431 </li>
432
433 <li>
434 <label for="give-export-userid">
435 <input type="checkbox" checked
436 name="give_give_donations_export_option[userid]"
437 id="give-export-userid"><?php _e( 'User ID', 'give' ); ?>
438 </label>
439 </li>
440
441 <li>
442 <label for="give-export-donorid">
443 <input type="checkbox" checked
444 name="give_give_donations_export_option[donorid]"
445 id="give-export-donorid"><?php _e( 'Donor ID', 'give' ); ?>
446 </label>
447 </li>
448
449 <li>
450 <label for="give-export-donor-ip">
451 <input type="checkbox" checked
452 name="give_give_donations_export_option[donor_ip]"
453 id="give-export-donor-ip"><?php _e( 'Donor IP Address', 'give' ); ?>
454 </label>
455 </li>
456
457 <?php
458 /*
459 * Action to add extra columns in standard donor fields
460 *
461 * @since 2.1
462 */
463 do_action( 'give_export_donation_standard_donor_fields' );
464 ?>
465 </ul>
466 </li>
467
468 <?php
469 /**
470 * Action to add custom export column.
471 *
472 * @since 2.1.4
473 */
474 do_action( 'give_export_donation_add_custom_column' );
475 ?>
476 </ul>
477 </div>
478 </td>
479 </tr>
480 <?php
481 }
482
483 add_action( 'give_export_donation_fields', 'give_export_donation_standard_fields', 10 );
484
485 /**
486 * Add Donation Custom fields in export donation page
487 *
488 * @since 2.1
489 */
490 function give_export_donation_custom_fields() {
491 ?>
492 <tr
493 class="give-hidden give-export-donations-hide give-export-donations-standard-fields">
494 <td scope="row" class="row-title">
495 <label><?php _e( 'Custom Field Columns:', 'give' ); ?></label>
496 </td>
497 <td class="give-field-wrap">
498 <div class="give-clearfix">
499 <ul class="give-export-option-ul"></ul>
500 <p class="give-field-description"><?php _e( 'The following fields may have been created by custom code, or another plugin.', 'give' ); ?></p>
501 </div>
502 </td>
503 </tr>
504 <?php
505 }
506
507 add_action( 'give_export_donation_fields', 'give_export_donation_custom_fields', 30 );
508
509
510 /**
511 * Add Donation hidden fields in export donation page
512 *
513 * @since 2.1
514 */
515 function give_export_donation_hidden_fields() {
516 ?>
517
518 <tr class="give-hidden give-export-donations-hide give-export-donations-hidden-fields">
519 <td scope="row" class="row-title">
520 <label><?php _e( 'Hidden Custom Field Columns:', 'give' ); ?></label>
521 </td>
522 <td class="give-field-wrap">
523 <div class="give-clearfix">
524 <ul class="give-export-option-ul"></ul>
525 <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>
526 </div>
527 </td>
528 </tr>
529 <?php
530 }
531
532 add_action( 'give_export_donation_fields', 'give_export_donation_hidden_fields', 40 );
533
534