PayPal Donations - Version 1.0

Version Description

Download this release

Release Info

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

Version 1.0

Files changed (4) hide show
  1. paypal-donations.php +225 -0
  2. readme.txt +50 -0
  3. screenshot-1.jpg +0 -0
  4. uninstall.php +8 -0
paypal-donations.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
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.0
7
+ Author: Johan Steen
8
+ Author URI: http://coding.cglounge.com/
9
+ Text Domain: paypal-donations
10
+
11
+ Copyright 2009 Johan Steen (email : artstorm [at] gmail [dot] com)
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
+ the Free Software Foundation; either version 2 of the License, or
16
+ (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+
28
+
29
+ class paypal_donations {
30
+ var $plugin_options = "paypal_donations_options";
31
+ var $donate_buttons = array("small" => "https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif",
32
+ "large" => "https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif",
33
+ "cards" => "https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif");
34
+ /**
35
+ * Constructor
36
+ *
37
+ */
38
+ function paypal_donations()
39
+ {
40
+ // define URL
41
+ define('paypal_donations_ABSPATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
42
+ define('paypal_donations_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
43
+
44
+ // Define the domain for translations
45
+ load_plugin_textdomain( 'paypal-donations', false, dirname(plugin_basename(__FILE__)) . '/languages/');
46
+
47
+ // Check installed Wordpress version.
48
+ global $wp_version;
49
+ if ( version_compare($wp_version, '2.7', '>=') ) {
50
+ // include_once (dirname (__FILE__)."/tinymce/tinymce.php");
51
+ $this->init_hooks();
52
+ } else {
53
+ $this->version_warning();
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Initializes the hooks for the plugin
59
+ *
60
+ * @returns Nothing
61
+ */
62
+ function init_hooks() {
63
+ add_action('admin_menu', array(&$this,'wp_admin'));
64
+ add_shortcode('paypal-donation', array(&$this,'paypal_shortcode'));
65
+ }
66
+
67
+ /**
68
+ * Displays a warning when installed in an old Wordpress Version
69
+ *
70
+ * @returns Nothing
71
+ */
72
+ function version_warning() {
73
+ echo '<div class="updated fade"><p><strong>'.__('PayPal Donations requires WordPress version 2.7 or later!', 'paypal-donations').'</strong></p></div>';
74
+ }
75
+
76
+ /**
77
+ * Create and register the PayPal shortcode
78
+ *
79
+ */
80
+ function paypal_shortcode($atts) {
81
+ $pd_options = get_option($this->plugin_options);
82
+ extract(shortcode_atts(array(
83
+ 'purpose' => $pd_options['purpose'],
84
+ 'reference' => $pd_options['reference'],
85
+ ), $atts));
86
+
87
+ $paypal_btn = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="donate">';
88
+ $paypal_btn .= '<div class="paypal-donations">';
89
+ $paypal_btn .= '<input type="hidden" name="cmd" value="_donations" />';
90
+ $paypal_btn .= '<input type="hidden" name="business" value="' .$pd_options['paypal_account']. '" />';
91
+
92
+ // Optional Settings
93
+ if ($pd_options['page_style'])
94
+ $paypal_btn .= '<input type="hidden" name="page_style" value="' .$pd_options['page_style']. '" />';
95
+ if ($pd_options['return_page'])
96
+ $paypal_btn .= '<input type="hidden" name="return" value="' .$pd_options['return_page']. '" />'; // Return Page
97
+ if ($purpose)
98
+ $paypal_btn .= '<input type="hidden" name="item_name" value="' .$purpose. '" />'; // Purpose
99
+ if ($reference)
100
+ $paypal_btn .= '<input type="hidden" name="item_number" value="' .$reference. '" />'; // LightWave Plugin
101
+
102
+ // Settings not implemented yet
103
+ // $paypal_btn .= '<input type="hidden" name="currency_code" value="SEK" />';
104
+ // $paypal_btn .= '<input type="hidden" name="amount" value="20" />';
105
+
106
+ // Get the button URL
107
+ if ( $pd_options['button'] == "custom" )
108
+ $button_url = $pd_options['button_url'];
109
+ else
110
+ $button_url = $this->donate_buttons[$pd_options['button']];
111
+
112
+ $paypal_btn .= '<input type="image" src="' .$button_url. '" name="submit" alt="PayPal - The safer, easier way to pay online." />';
113
+ $paypal_btn .= '<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />';
114
+ $paypal_btn .= '</div>';
115
+ $paypal_btn .= '</form>';
116
+
117
+ return $paypal_btn;
118
+ }
119
+
120
+ /**
121
+ * The Admin Page and all it's functions
122
+ *
123
+ */
124
+ function wp_admin() {
125
+ if (function_exists('add_options_page')) {
126
+ add_options_page( 'PayPal Donations Options', 'PayPal Donations', 10, __FILE__, array(&$this, 'options_page') );
127
+ }
128
+ }
129
+
130
+ function admin_message($message) {
131
+ if ( $message ) {
132
+ ?>
133
+ <div class="updated"><p><strong><?php echo $message; ?></strong></p></div>
134
+ <?php
135
+ }
136
+ }
137
+
138
+ function options_page() {
139
+ // Update Options
140
+ if (isset($_POST['Submit'])) {
141
+ $pd_options['paypal_account'] = trim( $_POST['paypal_account'] );
142
+ $pd_options['page_style'] = trim( $_POST['page_style'] );
143
+ $pd_options['return_page'] = trim( $_POST['return_page'] );
144
+ $pd_options['purpose'] = trim( $_POST['purpose'] );
145
+ $pd_options['reference'] = trim( $_POST['reference'] );
146
+ $pd_options['button'] = trim( $_POST['button'] );
147
+ $pd_options['button_url'] = trim( $_POST['button_url'] );
148
+ update_option($this->plugin_options, $pd_options);
149
+ $this->admin_message( __( 'The PayPal Donations settings have been updated.', 'paypal-donations' ) );
150
+ }
151
+ ?>
152
+ <div class=wrap>
153
+ <h2>PayPal Donations</h2>
154
+
155
+ <form method="post" action="">
156
+ <?php wp_nonce_field('update-options'); ?>
157
+ <?php $pd_options = get_option($this->plugin_options); ?>
158
+ <table class="form-table">
159
+ <tr valign="top">
160
+ <th scope="row"><label for="paypal_account"><?php _e( 'PayPal Account', 'paypal-donations' ) ?></label></th>
161
+ <td><input name="paypal_account" type="text" id="paypal_account" value="<?php echo $pd_options['paypal_account']; ?>" class="regular-text" /><span class="setting-description"><br/><?php _e( 'Your PayPal email address or your PayPal secure merchant account ID.', 'paypal-donations' ) ?></span></td>
162
+ </tr>
163
+ </table>
164
+
165
+ <h3><?php _e( 'Optional Settings', 'paypal-donations' ) ?></h3>
166
+ <table class="form-table">
167
+ <tr valign="top">
168
+ <th scope="row"><label for="page_style"><?php _e( 'Page Style', 'paypal-donations' ) ?></label></th>
169
+ <td><input name="page_style" type="text" id="page_style" value="<?php echo $pd_options['page_style']; ?>" class="regular-text" /><span class="setting-description"><br/><?php _e( 'Specify the name of a custom payment page style from your PayPal account profile.', 'paypal-donations' ) ?></span></td>
170
+ </tr>
171
+ <tr valign="top">
172
+ <th scope="row"><label for="return_page"><?php _e( 'Return Page', 'paypal-donations' ) ?></label></th>
173
+ <td><input name="return_page" type="text" id="return_page" value="<?php echo $pd_options['return_page']; ?>" class="regular-text" /><span class="setting-description"><br/><?php _e( 'URL to which the donator comes to after completing the donation; for example, a URL on your site that displays a "Thank you for your donation".', 'paypal-donations' ) ?></span></td>
174
+ </tr>
175
+ </table>
176
+
177
+ <h3><?php _e( 'Defaults', 'paypal-donations' ) ?></h3>
178
+ <table class="form-table">
179
+ <tr valign="top">
180
+ <th scope="row"><label for="purpose"><?php _e( 'Purpose', 'paypal-donations' ) ?></label></th>
181
+ <td><input name="purpose" type="text" id="purpose" value="<?php echo $pd_options['purpose']; ?>" class="regular-text" /><span class="setting-description"><br/><?php _e( 'The default purpose of a donation (Optional).', 'paypal-donations' ) ?></span></td>
182
+ </tr>
183
+ <tr valign="top">
184
+ <th scope="row"><label for="reference"><?php _e( 'Reference', 'paypal-donations' ) ?></label></th>
185
+ <td><input name="reference" type="text" id="reference" value="<?php echo $pd_options['reference']; ?>" class="regular-text" /><span class="setting-description"><br/><?php _e( 'Default reference for the donation (Optional).', 'paypal-donations' ) ?></span></td>
186
+ </tr>
187
+ </table>
188
+
189
+ <h3><?php _e( 'Donation Button', 'paypal-donations' ) ?></h3>
190
+ <table class="form-table">
191
+ <tr>
192
+ <th scope="row"><?php _e( 'Select Button', 'paypal-donations' ) ?></th>
193
+ <td>
194
+ <fieldset><legend class="hidden">PayPal Button</legend>
195
+ <?php
196
+ $custom = TRUE;
197
+ foreach ( $this->donate_buttons as $key => $button ) {
198
+ echo "\t<label title='" . attribute_escape($key) . "'><input style='padding: 10px 0 10px 0;' type='radio' name='button' value='" . attribute_escape($key) . "'";
199
+ if ( $pd_options['button'] === $key ) { // checked() uses "==" rather than "==="
200
+ echo " checked='checked'";
201
+ $custom = FALSE;
202
+ }
203
+ echo " /> <img src='" . $button . "' alt='" . $key . "' style='vertical-align: middle;' /></label><br /><br />\n";
204
+ }
205
+
206
+ echo ' <label><input type="radio" name="button" value="custom"';
207
+ checked( $custom, TRUE );
208
+ echo '/> ' . __('Custom Button:') . ' </label>';
209
+ ?>
210
+ <input type="text" name="button_url" value="<?php echo $pd_options['button_url']; ?>" class="regular-text" />
211
+ <p><span class="setting-description"><?php _e( 'Enter a URL to a custom donation button.', 'paypal-donations' ) ?></span></p>
212
+ </fieldset>
213
+ </td>
214
+ </tr>
215
+ </table>
216
+
217
+ <p class="submit">
218
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Changes', 'paypal-donations' ) ?>" />
219
+ </p>
220
+ </div>
221
+ <?php
222
+ }
223
+ }
224
+ add_action( 'plugins_loaded', create_function( '', 'global $paypal_donations; $paypal_donations = new paypal_donations();' ) );
225
+ ?>
readme.txt ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0
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 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
+
23
+ as an example.
24
+
25
+ This donation plugin generates valid XHTML Transitional and Strict code.
26
+
27
+ For complete usage instructions see: [PayPal Donations](http://coding.cglounge.com/wordpress-plugins/paypal-donations/ "Complete Usage Instructions for PayPal Donations")
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.0 - 7 May 2009 =
50
+ * Initial Release
screenshot-1.jpg ADDED
Binary file
uninstall.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
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
+ ?>