Created
August 15, 2024 17:58
-
-
Save rickalday/107e4826afcb31a306a94032e3cc87e3 to your computer and use it in GitHub Desktop.
Customize Email Acess link tag {email_access_link}
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 | |
add_filter('give_email_tag_email_access_link', 'custom_email_access_tag_link', 10, 2); | |
function custom_email_access_tag_link( $email_access_link, $tag_args ) { | |
// Set email access link if donor exist. | |
if ( ! empty( $tag_args['donor_id'] ) && $tag_args['verify_key'] ) { | |
$donor_id = absint( $tag_args['donor_id'] ); | |
$access_url = add_query_arg( | |
array( | |
'give_nl' => $tag_args['verify_key'], | |
), | |
give_get_history_page_uri() | |
); | |
// Add donation id to email access url, if it exists. | |
if ( ! empty( $_GET['donation_id'] ) ) { | |
$access_url = add_query_arg( | |
array( | |
'donation_id' => give_clean( $_GET['donation_id'] ), | |
), | |
$access_url | |
); | |
} | |
$email_access_link = sprintf( | |
'<a href="%1$s" target="_blank" style="background: #008345;color: #ffffff !important;margin: 20px auto;padding: 12px 20px;border-radius: 3px;text-decoration: none;font-weight: 600;width: 200px;text-align: center; display:block;">%2$s</a>', | |
esc_url( $access_url ), | |
__( 'View your subscription donations »', 'give-recurring' ) | |
); | |
} | |
return $email_access_link; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment