X

Paypal Donation Shortcode

Add shortcodes to handle Paypal donation links.

This code will make it simpler to accept paypal donations.

To use it, simply place the above snippet in your functions.php file and use any of the shortcodes below.

Code Snippet:

[donate]<br />
[donate]Donate Now[/donate]<br />
[donate account="you@yoursite.com" onHover="Thanks" for="Title"]<br />
[donate account="you@yoursite.com" onHover="Thanks" for="Title"]Donate Now[/donate]

This code comes with three different attributes: $account, $onHover and $for. The $account receives your paypal email address(default is your admin email address), the $onHover variable sets the anchor title attribute as you hover over the link and the $for attribute is the title of the Donation(default is your post title).

Code Snippet:

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

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!