PayPal Donations - Version 1.2

Version Description

Download this release

Release Info

Developer artstorm
Plugin Icon 128x128 PayPal Donations
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

Files changed (4) hide show
  1. paypal-donations.php +146 -8
  2. readme.txt +26 -12
  3. screenshot-2.jpg +0 -0
  4. uninstall.php +0 -8
paypal-donations.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: PayPal Donations
4
  Plugin URI: http://coding.cglounge.com/wordpress-plugins/paypal-donations/
5
- Description: Easy and simple setup and insertion of PayPal donate buttons with a shortcode. Donation purpose can be set for each button. A few other customization options are available as well.
6
- Version: 1.1
7
  Author: Johan Steen
8
  Author URI: http://coding.cglounge.com/
9
  Text Domain: paypal-donations
@@ -80,6 +80,9 @@ class paypal_donations {
80
  function init_hooks() {
81
  add_action('admin_menu', array(&$this,'wp_admin'));
82
  add_shortcode('paypal-donation', array(&$this,'paypal_shortcode'));
 
 
 
83
  }
84
 
85
  /**
@@ -91,18 +94,40 @@ class paypal_donations {
91
  echo '<div class="updated fade"><p><strong>'.__('PayPal Donations requires WordPress version 2.7 or later!', 'paypal-donations').'</strong></p></div>';
92
  }
93
 
 
 
 
 
 
 
 
 
94
  /**
95
  * Create and register the PayPal shortcode
96
  *
97
  */
98
  function paypal_shortcode($atts) {
99
- $pd_options = get_option($this->plugin_options);
100
  extract(shortcode_atts(array(
101
- 'purpose' => $pd_options['purpose'],
102
- 'reference' => $pd_options['reference'],
103
  ), $atts));
104
 
105
- $paypal_btn = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="donate">';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  $paypal_btn .= '<div class="paypal-donations">';
107
  $paypal_btn .= '<input type="hidden" name="cmd" value="_donations" />';
108
  $paypal_btn .= '<input type="hidden" name="business" value="' .$pd_options['paypal_account']. '" />';
@@ -134,10 +159,10 @@ class paypal_donations {
134
  $paypal_btn .= '<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />';
135
  $paypal_btn .= '</div>';
136
  $paypal_btn .= '</form>';
137
-
138
  return $paypal_btn;
139
  }
140
-
141
  /**
142
  * The Admin Page and all it's functions
143
  *
@@ -255,5 +280,118 @@ class paypal_donations {
255
  <?php
256
  }
257
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  add_action( 'plugins_loaded', create_function( '', 'global $paypal_donations; $paypal_donations = new paypal_donations();' ) );
 
259
  ?>
2
  /*
3
  Plugin Name: PayPal Donations
4
  Plugin URI: http://coding.cglounge.com/wordpress-plugins/paypal-donations/
5
+ Description: Easy and simple setup and insertion of PayPal donate buttons with a shortcode or through a sidebar Widget. Donation purpose can be set for each button. A few other customization options are available as well.
6
+ Version: 1.2
7
  Author: Johan Steen
8
  Author URI: http://coding.cglounge.com/
9
  Text Domain: paypal-donations
80
  function init_hooks() {
81
  add_action('admin_menu', array(&$this,'wp_admin'));
82
  add_shortcode('paypal-donation', array(&$this,'paypal_shortcode'));
83
+ global $wp_version;
84
+ if ( version_compare($wp_version, '2.8', '>=') )
85
+ add_action( 'widgets_init', array(&$this,'load_widget') );
86
  }
87
 
88
  /**
94
  echo '<div class="updated fade"><p><strong>'.__('PayPal Donations requires WordPress version 2.7 or later!', 'paypal-donations').'</strong></p></div>';
95
  }
96
 
97
+ /**
98
+ * Register the Widget
99
+ *
100
+ */
101
+ function load_widget() {
102
+ register_widget( 'paypal_donations_Widget' );
103
+ }
104
+
105
  /**
106
  * Create and register the PayPal shortcode
107
  *
108
  */
109
  function paypal_shortcode($atts) {
 
110
  extract(shortcode_atts(array(
111
+ 'purpose' => '',
112
+ 'reference' => '',
113
  ), $atts));
114
 
115
+ return $this->generate_html($purpose, $reference);
116
+ }
117
+
118
+ /**
119
+ * Generate the PayPal button HTML code
120
+ *
121
+ */
122
+ function generate_html($purpose = null, $reference = null) {
123
+ $pd_options = get_option($this->plugin_options);
124
+
125
+ // Set overrides for purpose and reference if defined
126
+ $purpose = (!$purpose) ? $pd_options['purpose'] : $purpose;
127
+ $reference = (!$reference) ? $pd_options['reference'] : $reference;
128
+
129
+ # Build the button
130
+ $paypal_btn = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
131
  $paypal_btn .= '<div class="paypal-donations">';
132
  $paypal_btn .= '<input type="hidden" name="cmd" value="_donations" />';
133
  $paypal_btn .= '<input type="hidden" name="business" value="' .$pd_options['paypal_account']. '" />';
159
  $paypal_btn .= '<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />';
160
  $paypal_btn .= '</div>';
161
  $paypal_btn .= '</form>';
162
+
163
  return $paypal_btn;
164
  }
165
+
166
  /**
167
  * The Admin Page and all it's functions
168
  *
280
  <?php
281
  }
282
  }
283
+
284
+
285
+ /**
286
+ * The Class for the Widget
287
+ *
288
+ */
289
+ if (class_exists('WP_Widget')) :
290
+ class paypal_donations_Widget extends WP_Widget {
291
+ /**
292
+ * Constructor
293
+ *
294
+ */
295
+ function paypal_donations_Widget() {
296
+ // Widget settings.
297
+ $widget_ops = array ( 'classname' => 'widget_paypal_donations', 'description' => 'PayPal Donation Button' );
298
+
299
+ // Widget control settings.
300
+ $control_ops = array( 'id_base' => 'paypal_donations' );
301
+
302
+ // Create the Widget
303
+ $this->WP_Widget( 'paypal_donations', 'PayPal Donations', $widget_ops );
304
+ }
305
+
306
+ /**
307
+ * Output the Widget
308
+ *
309
+ */
310
+ function widget( $args, $instance ) {
311
+ extract( $args );
312
+ global $paypal_donations;
313
+
314
+ // Get the settings
315
+ $title = apply_filters('widget_title', $instance['title'] );
316
+ $text = $instance['text'];
317
+ $purpose = $instance['purpose'];
318
+ $reference = $instance['reference'];
319
+
320
+ echo $before_widget;
321
+ if ( $title )
322
+ echo $before_title . $title . $after_title;
323
+ if ( $text )
324
+ echo wpautop( $text );
325
+ echo $paypal_donations->generate_html( $purpose, $reference );
326
+ echo $after_widget;
327
+ }
328
+
329
+ /**
330
+ * Saves the widgets settings.
331
+ *
332
+ */
333
+ function update( $new_instance, $old_instance ) {
334
+ $instance = $old_instance;
335
+
336
+ $instance['title'] = strip_tags(stripslashes($new_instance['title']));
337
+ $instance['text'] = $new_instance['text'];
338
+ $instance['purpose'] = strip_tags(stripslashes($new_instance['purpose']));
339
+ $instance['reference'] = strip_tags(stripslashes($new_instance['reference']));
340
+
341
+ return $instance;
342
+ }
343
+
344
+ /**
345
+ * The Form in the Widget Admin Screen
346
+ *
347
+ */
348
+ function form( $instance ) {
349
+ // Default Widget Settings
350
+ $defaults = array( 'title' => __('Donate', 'paypal-donations'), 'text' => '', 'purpose' => '', 'reference' => '' );
351
+ $instance = wp_parse_args( (array) $instance, $defaults ); ?>
352
+
353
+ <p>
354
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'paypal-donations'); ?>
355
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" />
356
+ </label>
357
+ </p>
358
+
359
+ <p>
360
+ <label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Text:', 'paypal-donations'); ?>
361
+ <textarea class="widefat" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo esc_attr($instance['text']); ?></textarea>
362
+ </label>
363
+ </p>
364
+
365
+ <p>
366
+ <label for="<?php echo $this->get_field_id('purpose'); ?>"><?php _e('Purpose:', 'paypal-donations'); ?>
367
+ <input class="widefat" id="<?php echo $this->get_field_id('purpose'); ?>" name="<?php echo $this->get_field_name('purpose'); ?>" type="text" value="<?php echo esc_attr($instance['purpose']); ?>" />
368
+ </label>
369
+ </p>
370
+
371
+ <p>
372
+ <label for="<?php echo $this->get_field_id('reference'); ?>"><?php _e('Reference:', 'paypal-donations'); ?>
373
+ <input class="widefat" id="<?php echo $this->get_field_id('reference'); ?>" name="<?php echo $this->get_field_name('reference'); ?>" type="text" value="<?php echo esc_attr($instance['reference']); ?>" />
374
+ </label>
375
+ </p>
376
+ <?php
377
+ }
378
+ }
379
+ endif;
380
+
381
+ /**
382
+ * Uninstall
383
+ * Clean up the WP DB by deleting the options created by the plugin.
384
+ *
385
+ */
386
+ if ( function_exists('register_uninstall_hook') )
387
+ register_uninstall_hook(__FILE__, 'paypal_donations_deinstall');
388
+
389
+ function paypal_donations_deinstall() {
390
+ delete_option('paypal_donations_options');
391
+ delete_option('widget_paypal_donations');
392
+ }
393
+
394
+ // Start the Plugin
395
  add_action( 'plugins_loaded', create_function( '', 'global $paypal_donations; $paypal_donations = new paypal_donations();' ) );
396
+
397
  ?>
readme.txt CHANGED
@@ -1,22 +1,28 @@
1
  === PayPal Donations ===
2
  Contributors: artstorm
3
  Donate link: http://coding.cglounge.com/wordpress-plugins/paypal-donations/#pintware
4
- Tags: paypal, donation, shortcode, donate, button
5
  Requires at least: 2.7
6
- Tested up to: 2.7.1
7
- Stable tag: 1.1
8
 
9
- Easy and simple setup and insertion of PayPal donate buttons with a shortcode. Donation purpose can be set for each button. A few other customization options are available as well.
10
 
11
  == Description ==
12
 
13
- Adds a PayPal donation shortcode to WordPress. The options menu lets you setup you PayPal ID and a few other optional settings. You can choose which donation button you want to use or if you want to use your own button. You can also set an optional default purpose and reference which can be overridden on each inserted instance with the shortcode options. There is also settings for currency, custom payment page style and the return page.
 
 
 
 
 
 
14
 
15
  Insert the button in your pages or posts with this shortcode
16
 
17
  `[paypal-donation]`
18
 
19
- Which is the simples option, and uses all default and optional settings. If you want to make a specific button for a specific purpose you can add these options:
20
 
21
  `[paypal-donation purpose="Spline Importer" reference="3D Plugins"]`
22
 
@@ -28,27 +34,35 @@ For complete usage instructions see: [PayPal Donations](http://coding.cglounge.c
28
 
29
  == Installation ==
30
 
31
- **Install**
32
 
33
  1. Upload the 'paypal-donations' folder to the '/wp-content/plugins/' directory.
34
  2. Activate the plugin through the 'Plugins' menu in WordPress.
35
  3. Go to Settings -> PayPal Donations and start entering your info.
36
 
37
- == Frequently Asked Questions ==
38
 
39
- = Guru? =
 
 
40
 
41
- Meditation.
 
 
42
 
43
  == Screenshots ==
44
 
45
- 1. The Admin page where you setup the plugin
 
46
 
47
  == Changelog ==
48
 
 
 
 
49
  = Version 1.1 - 23 May 2009 =
50
  * Added an option to select the currency to make the donations in.
51
  * Changed the default button in a new install from a custom button to the large button.
52
 
53
  = Version 1.0 - 7 May 2009 =
54
- * Initial Release
1
  === PayPal Donations ===
2
  Contributors: artstorm
3
  Donate link: http://coding.cglounge.com/wordpress-plugins/paypal-donations/#pintware
4
+ Tags: paypal, donation, shortcode, widget, donate, button, sidebar
5
  Requires at least: 2.7
6
+ Tested up to: 2.8
7
+ Stable tag: 1.2
8
 
9
+ Easy and simple setup and insertion of PayPal donate buttons with a shortcode or through a sidebar Widget. Donation purpose can be set for each button. A few other customization options are available as well.
10
 
11
  == Description ==
12
 
13
+ Adds a PayPal donation shortcode and sidebar Widget to WordPress. The options menu lets you setup you PayPal ID and a few other optional settings. You can choose which donation button you want to use or if you want to use your own button. You can also set an optional default purpose and reference which can be overridden on each inserted instance with the shortcode options or in the Widget settings. There is also options available for currency, custom payment page style and the return page.
14
+
15
+ = Widget =
16
+
17
+ In the Appearance -> Widgets in WordPress 2.8 or newer you'll find the PayPal Donations widget. After adding it to your sidebar you can enter a title for the Widget, some descriptive text that will appear above the button and specify an optional purpose and reference for the donation button to override the default settings.
18
+
19
+ = Shortcode =
20
 
21
  Insert the button in your pages or posts with this shortcode
22
 
23
  `[paypal-donation]`
24
 
25
+ Which is the simplest option, and uses all default and optional settings. If you want to make a specific button for a specific purpose you can add these options:
26
 
27
  `[paypal-donation purpose="Spline Importer" reference="3D Plugins"]`
28
 
34
 
35
  == Installation ==
36
 
37
+ = Install =
38
 
39
  1. Upload the 'paypal-donations' folder to the '/wp-content/plugins/' directory.
40
  2. Activate the plugin through the 'Plugins' menu in WordPress.
41
  3. Go to Settings -> PayPal Donations and start entering your info.
42
 
43
+ = Uninstall =
44
 
45
+ 1. Deactivate PayPal Donations in the 'Plugins' menu in Wordpress.
46
+ 2. After Deactivation a 'Delete' link appears below the plugin name, follow the link and confim with 'Yes, Delete these files'.
47
+ 3. This will delete all the plugin files from the server as well as erasing all options the plugin has stored in the database.
48
 
49
+ == Frequently Asked Questions ==
50
+
51
+ Please visit [PayPal Donations' Comments](http://coding.cglounge.com/wordpress-plugins/paypal-donations/#comments) for questions and answers.
52
 
53
  == Screenshots ==
54
 
55
+ 1. Admin page where you setup the plugin
56
+ 1. Sidebar Widget Admin Options
57
 
58
  == Changelog ==
59
 
60
+ = Version 1.2 - 18 June 2009 =
61
+ * Added a sidebar Widget (WordPress 2.8 or newer)
62
+
63
  = Version 1.1 - 23 May 2009 =
64
  * Added an option to select the currency to make the donations in.
65
  * Changed the default button in a new install from a custom button to the large button.
66
 
67
  = Version 1.0 - 7 May 2009 =
68
+ * Initial Release
screenshot-2.jpg ADDED
Binary file
uninstall.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
- /**
3
- * Uninstall
4
- * Clean up the WP DB by deleting the options created by the plugin.
5
- *
6
- */
7
- delete_option('paypal_donations_options');
8
- ?>