Created
March 21, 2023 15:43
-
-
Save rickalday/8f2ecedf9c9754f1960c16ad0c3d0587 to your computer and use it in GitHub Desktop.
Add Anonymous Donation fields in CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add Anonymous Donation Data fields in export donor fields tab. | |
*/ | |
function give_anonymous_donation_standard_donor_fields() { | |
?> | |
<li> | |
<label for="give-anonymous-donations"> | |
<input type="checkbox" checked | |
name="give_give_donations_export_option[give_anonymous_donation]" | |
id="give_anonymous_donation"><?php _e( 'Anonymous Donation', 'give' ); ?> | |
</label> | |
</li> | |
<?php | |
} | |
add_action( 'give_export_donation_standard_donor_fields', 'give_anonymous_donation_standard_donor_fields' ); | |
/** | |
* Add Anonymous Donation header in CSV. | |
*/ | |
function give_anonymous_donation_update_columns_heading( $cols ) { | |
if ( isset( $cols['give_anonymous_donation'] ) ) { | |
$cols['give_anonymous_donation'] = __( '_give_anonymous_donation', 'give' ); | |
} | |
return $cols; | |
} | |
add_filter( 'give_export_donation_get_columns_name', 'give_anonymous_donation_update_columns_heading' ); | |
<?php | |
/** | |
* Add Anonymous Donation fields in CSV. | |
*/ | |
function give_anonymous_donation_export_donation_data( $data, $payment, $columns ) { | |
if ( ! empty( $columns['give_anonymous_donation'] ) ) { | |
$message = $payment->get_meta( '_give_anonymous_donation' ); | |
if ( $message == 1 ){ | |
$data['give_anonymous_donation'] = '1'; | |
} else { | |
$data['give_anonymous_donation'] = ''; | |
} | |
} | |
return $data; | |
} | |
add_filter( 'give_export_donation_data', 'give_anonymous_donation_export_donation_data', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment