Simple PayPal Donate provides a basic ability to display PayPal donation buttons on your blog.
As well as making it easier to control your output, this plugin assists with multiple occurrences across a WordPress installation (maintaining a single point for the code, particularly useful if the code changes in future). It is also XHTML compliant, unlike the original PayPal code.
Step 1: Create your button
If you’ve not done so already, create your donation button…
Here is an example of the code produced for the donation button on the artiss site…
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="2851382">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="">
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
The button ID, if present, is the 7 digit numeric value usually at the end of the third line of code (e.g. '2851382'). If this is not present you may have an encryped value instead (this has a value containing a long string of characters, with -BEGIN near the start of the value). Either one of these can be used in this plugin.
The image URL is the "src" usually on the 4th line (e.g. 'https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif').
Step 2: Create the code
To display your PayPal Button on your WordPress site you will need to insert the following code, where appropriate, into your theme…
<?php simple_paypal_donate('9999999','https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif'); ?>
You will need to replace some of the above details with those that I suggested you note before, as supplied by PayPal. The first parameter is your button ID or encrypted value (either will work) and the second parameter is the image URL.
If you wish to ensure that your code still works correctly, even if Simple PayPal Donate is switched off, you can use the following format of code…
<?php if (function_exists('simple_paypal_donate')) simple_paypal_donate('2851382','https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif'); ?>
Alternatively, since version 1.2 you can specify the button ID using the parameter id=. When using this method you can use additional sub-parameters. These are...
target= : specify a link TARGET (default is no TARGET is specified).
alt= : change the default image ALT text. This can't include an ampersand, otherwise it will be interpreted as an additional sub-parameter.
When using multiple sub-parameters, they must be separated with an ampersand.
For example...
<?php simple_paypal_donate('id=2851382&target=_self&alt=Donate!','https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif'); ?>
As the first parameter we have specified thre sub-parameters - the button ID, the link TARGET and the ALT text.
Using the shortcode
Alternatively, if you wish to add a PayPal donation button directly into a specific page or post then you can use a WordPress shortcode.
Simply type [paypal] wherever you wish the button to appear, but with the following options...
id : the button ID or encrypted value (required)
image : the image URL (required)
target : link target (optional)
alt : ALT image text (optional)
For example...
[paypal id=9999999 image="https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif"]
Returning a link
If you wish to not generate button, but simply need a link to the PayPal donation page, then a simple function call is available that will return the appropriate URL - paypal_link. To use, simply supply the button ID (the encrypted value does not work in this situation).
For example....
<a href="<?php echo paypal_link('9999999'); ?>">Please donate</a>
For help with this plugin, or simply to comment or get in touch, please read the appropriate section in "Other Notes" for details. This plugin, and all support, is supplied for free, but donations are always welcome.
Requires: 2.0 or higher
Compatible up to: 3.0.5
Last Updated: 2010-7-5
Downloads: 7,831




