WordPress Plugin: Paypal Donate (Version 1.1)

wordpress-3-1The original WordPress PayPal Donate is a plugin written by Mikhail Esteves in 2006. This plugin allows for the easy inclusion of Paypal Donate buttons in WordPress posts and pages. On the option page the generated donate button code provided by PayPal can be saved to a form and the pre-defined tag may be applied to individual posts or pages.

Although this plugin is still in circulation and functional, I rewrote portions of the plugin to take advantage of the more modern functions that WordPress offers including shortcodes.

Although, the original plugin is functional, I rewrote a significant portion of it so that it would be more compliant with the more recent versions of WordPress. This code is more efficient and produces the same results as the original code. Since the original code has not been maintained since 2006, eventually it will break. This update should ensure that the plugin does not become depreciated.

Before I continue, I want to note that I am not a programmer, I respect the original code and the author, I am not certain that the code is the most efficient code, and this is just a test to sharpen my skills.

For example, here is the original code for paypaldonate.php as it is for version 1.0.

Plugin Name: Paypal Donate
Plugin URI: http://www.thejackol.com/2006/11/16/wordpress-plugin-paypal-donate/
Description: Allows easy addition of Paypal donate buttons in pages and posts.
Author: Mikhail Esteves
Author URI: http://www.thejackol.com/
Version: 1.0

function wppd_callback( $content )
if (!preg_match('|<!--donate-->|', $content)){
return $content;
$results = stripslashes(get_option('wppd_code'));
echo str_replace('<!--donate-->', $results, $content);

function wppd_add_options_page()
// Enable if you would like the Options sub-menu in the Options tab.
//add_options_page('Paypal Donate Options', 'Paypal Donate', 'manage_options', 'paypal-donate/options-paypaldonate.php');

add_submenu_page('plugins.php', __('Paypal Donate Options'), __('Paypal Donate Options'), 'manage_options', 'paypal-donate/options-paypaldonate.php');

add_action('admin_head', 'wppd_add_options_page');
add_filter('the_content', 'wppd_callback');

Here is my revised code for version 1.1.

Plugin Name: Paypal Donate
Plugin URI: https://it.megocollector.com/
Description: Allows easy addition of PayPal donate buttons in pages and posts.
Author: Mikhail Esteves revised by Paul M. Combs, Jr.
Author URI: https://it.megocollector.com/
Version: 1.1

add_action('admin_menu', 'wppd_add_options_page');
add_shortcode('donate', 'wppd_shortcode');

function wppd_shortcode() {
$results = stripslashes(get_option('wppd_code'));
return 'If you find this information useful, please donate.'.$results;

function wppd_add_options_page() {
add_options_page('Paypal Donate Options', 'Paypal Donate', 'manage_options', 'paypal-donate/options-paypaldonate.php');



  PayPal Donate (2.4 KiB, 1,467 hits)


  • Upload contents of the ZIP file to your wp-content/plugins folder.
  • Activate the “PayPal Donate” plugin
  • You’ll see a “PayPal Donate” under Settings on the Admin page. Go there.
  • Use PayPal’s Merchant Tools to generate a PayPal Donate button.
  • Paste the provided code in the Options page.
  • Edit the post/page in WordPress where you want the Donation button to appear.
  • Add donate in [] anywhere in the post/page where you want the donation button to appear.


More details available in the readme.txt file.
BTW: Here is a working example of PayPal Donate