Forked from rickalday/give_anonymous_email_tag.php
Last active
June 13, 2020 17:36
GiveWP Anonymous Donation Email Tag
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 | |
// Plugin Name: GiveWP Add Email Tag for Anonymous Checkbox | |
function give_anonymous_email_tag( $email_tags ) { | |
// Adds an email tag called {give_anonymous_status} to indicate whether the donor opted in or not. | |
$email_tags[] = array( | |
'tag' => 'give_anonymous_status', // The tag name. | |
'desc' => __( 'This outputs whether the donor opted-in to the anonymous option', 'give' ), // For admins. | |
'func' => 'render_give_anonymous_status_email_tag', // Callback to function below. | |
'context' => 'donation', | |
); | |
return $email_tags; | |
} | |
add_filter( 'give_email_tags', 'give_anonymous_email_tag', 999, 1 ); | |
function render_give_anonymous_status_email_tag( $tag_args ) { | |
$opt_in_meta = give_get_meta( $tag_args['payment_id'], '_give_anonymous_donation', true ); | |
if ( $opt_in_meta ) { | |
$output = __( 'Anonymous donation', 'give' ); | |
} else { | |
$output = __( 'Not an anonymous donation', 'give' ); | |
} | |
return apply_filters( 'give_email_tag_give_anonymous_status', $output, $tag_args ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment