Shortcode: Add a Paypal Donation button

Add following code where you want to display it.

Usage

[paypaldonate account='paypal-email-address' for='enter-what-donation-is-for' onHover='Thank you']Make A Donation[/paypaldonate]

Add following snippet to “functions.php”

Snippet

add_shortcode('paypaldonate', 'wpds_donate_shortcode');
function wpds_donate_shortcode( $atts, $content = null) {
 
    global $post;
     
    extract(shortcode_atts(array(
    'account' => 'paypal-email-address',
    'for' => $post->post_title,
    'onHover' => '',
    ), $atts));
     
    if(empty($content)) $content='Donate';
     
    return '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business='.$account.'&amp;item_name=Donation for '.$for.'" title="'.$onHover.'">'.$content.'</a>';
}

Result

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>