Created
June 21, 2024 00:10
-
-
Save rickalday/e7ad9c574b7bf1713eb97b65046d3aac to your computer and use it in GitHub Desktop.
Export FFM Phone
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
<?php | |
function export_option_givewp_ffm_phone() { | |
?> | |
<tr class="give-export-option-fields give-export-option-custom-field"> | |
<td scope="row" class="row-title"> | |
<label><?php esc_html_e( 'Phone Number:', 'give' ); ?></label> | |
</td> | |
<td class="give-field-wrap"> | |
<div class="give-clearfix"> | |
<ul class="give-export-option-custom-fields-ul"> | |
<!-- Custom field checkbox --> | |
<li class="give-export-option-start"> | |
<label for="give-custom-field"> | |
<input type="checkbox" checked | |
name="give_give_donations_export_option[ffm-phone]" | |
id="ffm-phone"><?php _e( 'Phone Number', 'give' ); ?> | |
</label> | |
</li> | |
</ul> | |
</div> | |
</td> | |
</tr> | |
<?php | |
} | |
add_action( 'give_export_donation_fields', 'export_option_givewp_ffm_phone' ); | |
/** | |
* This function sets the column header in the generated CSV file for the custom field. Add an if statement for each aditional field. | |
*/ | |
function column_header_givewp_ffm_phone( $cols ) { | |
if ( isset( $cols['ffm-phone'] ) ) { | |
$cols['ffm-phone'] = __( 'FFM Phone', 'give' ); | |
} | |
return $cols; | |
} | |
add_filter( 'give_export_donation_get_columns_name', 'column_header_givewp_ffm_phone' ); | |
/** | |
* This function populates the CSV with the custom field data. Add an if statement for each aditional field. | |
*/ | |
function export_givewp_ffm_phone( $data, $payment, $columns ) { | |
if ( ! empty( $columns['ffm-phone'] ) ) { | |
$data['ffm-phone'] = ''; | |
$phone = $payment->get_meta( 'phone' ); | |
if ($phone ) { | |
$data['ffm-phone'] = $phone; | |
} | |
} | |
return $data; | |
} | |
add_filter( 'give_export_donation_data', 'export_givewp_ffm_phone', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment