Simple PayPal Donate
Simple PayPal Donate is a WordPress plugin that 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.
Download
Download Simple PayPal Donate (v1.3, 05/07/2010)
Changelog
Version 1.0
- Initial release
Version 1.1
- On some PayPal servers a different version of the code was being used which supplied different parameters. This version takes this into account and allows both types to be specified. Thanks to John Kalogerakos for highlighting this to me.
Version 1.2
- Added sub-parameter option, allowing a
TARGETto be specified for links and an override for theALTtext. I’ve made this backward compatible with the parameter options before this version. - Modified the default image
ALTtext
Version 1.3
- If no
TARGETis specified then it is not assigned –TARGETis not compatible with XHTML STRICT - Resulting XHTML code is better formatted, with comments identifying code location
- Confirmed WP 3.0 compatibility and that PayPal code is the latest
Installation
- Upload the entire
simple-paypal-donatefolder to yourwp-content/plugins/directory. - Activate the plugin through the ‘Plugins’ menu in WordPress.
- There is no options screen – configuration is done in your code and, optionally, by modifying the plugin.
Configuration
If you’ve not done so already, create your donation button…
- Log into your PayPal account
- The option to take donations can be found under “Merchant Services”
- Create the button, as required, and you will be shown some code to add to your website.
- Within this code is a button_id (or equivalent encrypted value) and image URL – you will need these for the Simple PayPal Donate plugin to work.
Here is an example of the code produced for the donation button on the artiss.co.uk 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 is usually the 7 digit numeric value at the end of the third line of code (“2851382“). If this is not present you may have an encrypted 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 usually the “src” on the 4th line (“https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif“).
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('2851382',
'https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif'); ?>
In the above example, I’ve used my credentials, but you will need to use the details 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.
Alternatively, 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= : override the standard link TARGET of _BLANK.
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 three sub-parameters – the button ID, the link TARGET and the ALT text.
Applying Styles
You can apply CSS styles to the donation button as the button is within a FORM and this has an ID of ‘donate’.
For example, the following CSS will “float” the button to the right hand side…
#donate {float: right;}
Mentions/Reviews
Problems/Queries
Please report any problems, or suggestions for enhancements, to me either via my contact form or by commenting on the appropriate entries on my blog.
Updates
Updates to this and any other of my WordPress plugins will be published on this blog.
























Improving WordPress Search Further
Artiss.co.uk is checked by
all my code is encrypted and no way to find ID
Version 1.1 of the plugin was launched to specifically deal with this issue (it would appear that PayPal generated different code on different servers!). Instead of specifying the missing button ID as the first parameter instead pass the encrypted value.
Can anyone help me get rid of the white background behind the gif. The gif is oval but it makes it square with this code. I cant seem to add the border=”0″ and make it work correctly.
Here is the code I am using:
And this is my CSS section:
#donate {
float:;
background: #2a2a2a;
border: 0px solid #2a2a2a;
Left;
}
The image is a GIF supplied by PayPal – I suspect they haven’t set transparency on around the image, hence the white is showing. When specifying the details of your donation button via the PayPal site, you can supply your own image – I’d suggest doing this.