Version Description
Download this release
Release Info
Developer | artstorm |
Plugin | PayPal Donations |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.9.6 to 1.5
- classes/settings.php +171 -0
- paypal-donations.php +134 -122
- readme.txt +34 -24
classes/settings.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PayPal Donations Settings.
|
4 |
+
*
|
5 |
+
* Class that renders out the HTML for the settings screen and contains helpful
|
6 |
+
* methods to simply the maintainance of the admin screen.
|
7 |
+
*
|
8 |
+
* @package PayPal Donations
|
9 |
+
* @author Johan Steen <artstorm at gmail dot com>
|
10 |
+
* @since Post Snippets 1.5
|
11 |
+
*/
|
12 |
+
class Paypal_Donations_Settings
|
13 |
+
{
|
14 |
+
private $plugin_options;
|
15 |
+
private $currency_codes;
|
16 |
+
private $donate_buttons;
|
17 |
+
private $localized_buttons;
|
18 |
+
|
19 |
+
public function set_options( $options, $code, $buttons, $loc_buttons )
|
20 |
+
{
|
21 |
+
$this->plugin_options = $options;
|
22 |
+
$this->currency_codes = $code;
|
23 |
+
$this->donate_buttons = $buttons;
|
24 |
+
$this->localized_buttons = $loc_buttons;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function render()
|
28 |
+
{
|
29 |
+
?>
|
30 |
+
<div class=wrap>
|
31 |
+
<h2>PayPal Donations</h2>
|
32 |
+
|
33 |
+
<form method="post" action="">
|
34 |
+
<?php wp_nonce_field('update-options'); ?>
|
35 |
+
<?php // $pd_options = get_option($this->plugin_options);
|
36 |
+
$pd_options = $this->plugin_options;
|
37 |
+
?>
|
38 |
+
<table class="form-table">
|
39 |
+
<tr valign="top">
|
40 |
+
<th scope="row"><label for="paypal_account"><?php _e( 'PayPal Account', 'paypal-donations' ) ?></label></th>
|
41 |
+
<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>
|
42 |
+
</tr>
|
43 |
+
<tr valign="top">
|
44 |
+
<th scope="row"><label for="currency_code"><?php _e( 'Currency', 'paypal-donations' ) ?></label></th>
|
45 |
+
<td><select name="currency_code" id="currency_code">
|
46 |
+
<?php if (isset($pd_options['currency_code'])) { $current_currency = $pd_options['currency_code']; } else { $current_currency = 'USD'; }
|
47 |
+
foreach ( $this->currency_codes as $key => $code ) {
|
48 |
+
echo '<option value="'.$key.'"';
|
49 |
+
if ($current_currency == $key) { echo ' selected="selected"'; }
|
50 |
+
echo '>'.$code.'</option>';
|
51 |
+
}?></select>
|
52 |
+
<span class="setting-description"><br/><?php _e( 'The currency to use for the donations.', 'paypal-donations' ) ?></span></td>
|
53 |
+
</tr>
|
54 |
+
</table>
|
55 |
+
|
56 |
+
<h3><?php _e( 'Optional Settings', 'paypal-donations' ) ?></h3>
|
57 |
+
<table class="form-table">
|
58 |
+
<tr valign="top">
|
59 |
+
<th scope="row"><label for="page_style"><?php _e( 'Page Style', 'paypal-donations' ) ?></label></th>
|
60 |
+
<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>
|
61 |
+
</tr>
|
62 |
+
<tr valign="top">
|
63 |
+
<th scope="row"><label for="return_page"><?php _e( 'Return Page', 'paypal-donations' ) ?></label></th>
|
64 |
+
<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>
|
65 |
+
</tr>
|
66 |
+
</table>
|
67 |
+
|
68 |
+
<h3><?php _e( 'Defaults', 'paypal-donations' ) ?></h3>
|
69 |
+
<table class="form-table">
|
70 |
+
<tr valign="top">
|
71 |
+
<th scope="row"><label for="amount"><?php _e( 'Amount', 'paypal-donations' ) ?></label></th>
|
72 |
+
<td><input name="amount" type="text" id="amount" value="<?php echo $pd_options['amount']; ?>" class="regular-text" /><span class="setting-description"><br/><?php _e( 'The default amount for a donation (Optional).', 'paypal-donations' ) ?></span></td>
|
73 |
+
</tr>
|
74 |
+
<tr valign="top">
|
75 |
+
<th scope="row"><label for="purpose"><?php _e( 'Purpose', 'paypal-donations' ) ?></label></th>
|
76 |
+
<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>
|
77 |
+
</tr>
|
78 |
+
<tr valign="top">
|
79 |
+
<th scope="row"><label for="reference"><?php _e( 'Reference', 'paypal-donations' ) ?></label></th>
|
80 |
+
<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>
|
81 |
+
</tr>
|
82 |
+
</table>
|
83 |
+
|
84 |
+
<h3><?php _e( 'Donation Button', 'paypal-donations' ) ?></h3>
|
85 |
+
<table class="form-table">
|
86 |
+
<tr>
|
87 |
+
<th scope="row"><?php _e( 'Select Button', 'paypal-donations' ) ?></th>
|
88 |
+
<td>
|
89 |
+
<fieldset><legend class="hidden">PayPal Button</legend>
|
90 |
+
<?php
|
91 |
+
$custom = TRUE;
|
92 |
+
if (isset($pd_options['button_localized'])) { $button_localized = $pd_options['button_localized']; } else { $button_localized = 'en_US'; }
|
93 |
+
if (isset($pd_options['button'])) { $current_button = $pd_options['button']; } else { $current_button = 'large'; }
|
94 |
+
foreach ( $this->donate_buttons as $key => $button ) {
|
95 |
+
echo "\t<label title='" . esc_attr($key) . "'><input style='padding: 10px 0 10px 0;' type='radio' name='button' value='" . esc_attr($key) . "'";
|
96 |
+
if ( $current_button === $key ) { // checked() uses "==" rather than "==="
|
97 |
+
echo " checked='checked'";
|
98 |
+
$custom = FALSE;
|
99 |
+
}
|
100 |
+
echo " /> <img src='" . str_replace('en_US', $button_localized, $button) . "' alt='" . $key . "' style='vertical-align: middle;' /></label><br /><br />\n";
|
101 |
+
}
|
102 |
+
|
103 |
+
echo ' <label><input type="radio" name="button" value="custom"';
|
104 |
+
checked( $custom, TRUE );
|
105 |
+
echo '/> ' . __('Custom Button:', 'paypal-donations') . ' </label>';
|
106 |
+
?>
|
107 |
+
<input type="text" name="button_url" value="<?php echo $pd_options['button_url']; ?>" class="regular-text" /><br/>
|
108 |
+
<span class="setting-description"><?php _e( 'Enter a URL to a custom donation button.', 'paypal-donations' ) ?></span>
|
109 |
+
</fieldset>
|
110 |
+
</td>
|
111 |
+
</tr>
|
112 |
+
<tr valign="top">
|
113 |
+
<th scope="row"><label for="button_localized"><?php _e( 'Country and Language', 'paypal-donations' ) ?></label></th>
|
114 |
+
<td><select name="button_localized" id="button_localized">
|
115 |
+
<?php foreach ( $this->localized_buttons as $key => $localize ) {
|
116 |
+
echo '<option value="'.$key.'"';
|
117 |
+
if ($button_localized == $key) { echo ' selected="selected"'; }
|
118 |
+
echo '>'.$localize.'</option>';
|
119 |
+
}?></select>
|
120 |
+
<span class="setting-description"><br/><?php _e( 'Localize the language and the country for the button (Updated after saving the settings).', 'paypal-donations' ) ?></span></td>
|
121 |
+
</tr>
|
122 |
+
</table>
|
123 |
+
|
124 |
+
<?php
|
125 |
+
// Extras
|
126 |
+
?>
|
127 |
+
<h3><?php _e( 'Extras', 'paypal-donations' ) ?></h3>
|
128 |
+
<p>Optional extra settings to fine tune the setup in certain scenarios.</p>
|
129 |
+
<?php
|
130 |
+
$this->checkbox(
|
131 |
+
__('Disable PayPal Statistics', 'paypal-donations'),
|
132 |
+
'disable_stats',
|
133 |
+
$pd_options['disable_stats']);
|
134 |
+
|
135 |
+
$this->checkbox(
|
136 |
+
__('Theme CSS Override: Center Button', 'paypal-donations'),
|
137 |
+
'center_button',
|
138 |
+
$pd_options['center_button']);
|
139 |
+
?>
|
140 |
+
|
141 |
+
<p class="submit">
|
142 |
+
<input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Changes', 'paypal-donations' ) ?>" />
|
143 |
+
</p>
|
144 |
+
</div>
|
145 |
+
|
146 |
+
|
147 |
+
<?php
|
148 |
+
}
|
149 |
+
|
150 |
+
// -------------------------------------------------------------------------
|
151 |
+
// HTML and Form element methods
|
152 |
+
// -------------------------------------------------------------------------
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Checkbox.
|
156 |
+
* Renders the HTML for an input checkbox.
|
157 |
+
*
|
158 |
+
* @param string $label The label rendered to screen
|
159 |
+
* @param string $name The unique name to identify the input
|
160 |
+
* @param boolean $checked If the input is checked or not
|
161 |
+
*/
|
162 |
+
private function checkbox( $label, $name, $checked )
|
163 |
+
{
|
164 |
+
printf( '<input type="checkbox" name="%s" value="true"', $name );
|
165 |
+
if ($checked)
|
166 |
+
echo ' checked';
|
167 |
+
echo ' />';
|
168 |
+
echo ' '.$label.'<br/>';
|
169 |
+
}
|
170 |
+
|
171 |
+
}
|
paypal-donations.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
Plugin Name: PayPal Donations
|
4 |
Plugin URI: http://wpstorm.net/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.
|
7 |
Author: Johan Steen
|
8 |
-
Author URI: http://
|
9 |
Text Domain: paypal-donations
|
10 |
|
11 |
-
Copyright
|
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
|
@@ -25,8 +25,8 @@ 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 |
-
|
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',
|
@@ -72,43 +72,42 @@ class Paypal_Donations {
|
|
72 |
'en_US' => 'United States - U.S. English');
|
73 |
|
74 |
public function __construct() {
|
75 |
-
// define URL
|
76 |
-
define('paypal_donations_ABSPATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
77 |
-
define('paypal_donations_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
78 |
-
|
79 |
// Define the domain for translations
|
80 |
load_plugin_textdomain( 'paypal-donations', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
81 |
|
82 |
-
|
83 |
-
global $wp_version;
|
84 |
-
if ( version_compare($wp_version, '2.7', '>=') )
|
85 |
-
$this->init_hooks();
|
86 |
-
else
|
87 |
-
$this->version_warning();
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
* Initializes the hooks for the plugin
|
92 |
*
|
93 |
-
* @
|
94 |
*/
|
95 |
function init_hooks() {
|
96 |
add_action('admin_menu', array(&$this,'wp_admin'));
|
97 |
add_shortcode('paypal-donation', array(&$this,'paypal_shortcode'));
|
|
|
|
|
|
|
98 |
global $wp_version;
|
99 |
if ( version_compare($wp_version, '2.8', '>=') )
|
100 |
add_action( 'widgets_init', array(&$this,'load_widget') );
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
-
*
|
105 |
-
*
|
106 |
-
* @returns Nothing
|
107 |
*/
|
108 |
-
function
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
-
|
112 |
/**
|
113 |
* Register the Widget
|
114 |
*
|
@@ -178,9 +177,12 @@ class Paypal_Donations {
|
|
178 |
// Get the button URL
|
179 |
if ( $pd_options['button'] != "custom" && !$button_url)
|
180 |
$button_url = str_replace('en_US', $button_localized, $this->donate_buttons[$pd_options['button']]);
|
181 |
-
|
182 |
$paypal_btn .= '<input type="image" src="' .$button_url. '" name="submit" alt="PayPal - The safer, easier way to pay online." />';
|
183 |
-
|
|
|
|
|
|
|
|
|
184 |
$paypal_btn .= '</div>';
|
185 |
$paypal_btn .= '</form>';
|
186 |
$paypal_btn .= "\n<!-- End PayPal Donations -->\n";
|
@@ -194,7 +196,7 @@ class Paypal_Donations {
|
|
194 |
*/
|
195 |
function wp_admin() {
|
196 |
if (function_exists('add_options_page'))
|
197 |
-
add_options_page( 'PayPal Donations Options', 'PayPal Donations', 'administrator', __FILE__, array(&$this, 'options_page') );
|
198 |
}
|
199 |
|
200 |
function admin_message($message) {
|
@@ -218,106 +220,20 @@ class Paypal_Donations {
|
|
218 |
$pd_options['currency_code'] = trim( $_POST['currency_code'] );
|
219 |
$pd_options['amount'] = trim( $_POST['amount'] );
|
220 |
$pd_options['button_localized'] = trim( $_POST['button_localized'] );
|
|
|
|
|
221 |
update_option($this->plugin_options, $pd_options);
|
222 |
$this->admin_message( __( 'The PayPal Donations settings have been updated.', 'paypal-donations' ) );
|
223 |
}
|
224 |
-
?>
|
225 |
-
<div class=wrap>
|
226 |
-
<h2>PayPal Donations</h2>
|
227 |
-
|
228 |
-
<form method="post" action="">
|
229 |
-
<?php wp_nonce_field('update-options'); ?>
|
230 |
-
<?php $pd_options = get_option($this->plugin_options); ?>
|
231 |
-
<table class="form-table">
|
232 |
-
<tr valign="top">
|
233 |
-
<th scope="row"><label for="paypal_account"><?php _e( 'PayPal Account', 'paypal-donations' ) ?></label></th>
|
234 |
-
<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>
|
235 |
-
</tr>
|
236 |
-
<tr valign="top">
|
237 |
-
<th scope="row"><label for="currency_code"><?php _e( 'Currency', 'paypal-donations' ) ?></label></th>
|
238 |
-
<td><select name="currency_code" id="currency_code">
|
239 |
-
<?php if (isset($pd_options['currency_code'])) { $current_currency = $pd_options['currency_code']; } else { $current_currency = 'USD'; }
|
240 |
-
foreach ( $this->currency_codes as $key => $code ) {
|
241 |
-
echo '<option value="'.$key.'"';
|
242 |
-
if ($current_currency == $key) { echo ' selected="selected"'; }
|
243 |
-
echo '>'.$code.'</option>';
|
244 |
-
}?></select>
|
245 |
-
<span class="setting-description"><br/><?php _e( 'The currency to use for the donations.', 'paypal-donations' ) ?></span></td>
|
246 |
-
</tr>
|
247 |
-
</table>
|
248 |
-
|
249 |
-
<h3><?php _e( 'Optional Settings', 'paypal-donations' ) ?></h3>
|
250 |
-
<table class="form-table">
|
251 |
-
<tr valign="top">
|
252 |
-
<th scope="row"><label for="page_style"><?php _e( 'Page Style', 'paypal-donations' ) ?></label></th>
|
253 |
-
<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>
|
254 |
-
</tr>
|
255 |
-
<tr valign="top">
|
256 |
-
<th scope="row"><label for="return_page"><?php _e( 'Return Page', 'paypal-donations' ) ?></label></th>
|
257 |
-
<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>
|
258 |
-
</tr>
|
259 |
-
</table>
|
260 |
-
|
261 |
-
<h3><?php _e( 'Defaults', 'paypal-donations' ) ?></h3>
|
262 |
-
<table class="form-table">
|
263 |
-
<tr valign="top">
|
264 |
-
<th scope="row"><label for="amount"><?php _e( 'Amount', 'paypal-donations' ) ?></label></th>
|
265 |
-
<td><input name="amount" type="text" id="amount" value="<?php echo $pd_options['amount']; ?>" class="regular-text" /><span class="setting-description"><br/><?php _e( 'The default amount for a donation (Optional).', 'paypal-donations' ) ?></span></td>
|
266 |
-
</tr>
|
267 |
-
<tr valign="top">
|
268 |
-
<th scope="row"><label for="purpose"><?php _e( 'Purpose', 'paypal-donations' ) ?></label></th>
|
269 |
-
<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>
|
270 |
-
</tr>
|
271 |
-
<tr valign="top">
|
272 |
-
<th scope="row"><label for="reference"><?php _e( 'Reference', 'paypal-donations' ) ?></label></th>
|
273 |
-
<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>
|
274 |
-
</tr>
|
275 |
-
</table>
|
276 |
-
|
277 |
-
<h3><?php _e( 'Donation Button', 'paypal-donations' ) ?></h3>
|
278 |
-
<table class="form-table">
|
279 |
-
<tr>
|
280 |
-
<th scope="row"><?php _e( 'Select Button', 'paypal-donations' ) ?></th>
|
281 |
-
<td>
|
282 |
-
<fieldset><legend class="hidden">PayPal Button</legend>
|
283 |
-
<?php
|
284 |
-
$custom = TRUE;
|
285 |
-
if (isset($pd_options['button_localized'])) { $button_localized = $pd_options['button_localized']; } else { $button_localized = 'en_US'; }
|
286 |
-
if (isset($pd_options['button'])) { $current_button = $pd_options['button']; } else { $current_button = 'large'; }
|
287 |
-
foreach ( $this->donate_buttons as $key => $button ) {
|
288 |
-
echo "\t<label title='" . esc_attr($key) . "'><input style='padding: 10px 0 10px 0;' type='radio' name='button' value='" . esc_attr($key) . "'";
|
289 |
-
if ( $current_button === $key ) { // checked() uses "==" rather than "==="
|
290 |
-
echo " checked='checked'";
|
291 |
-
$custom = FALSE;
|
292 |
-
}
|
293 |
-
echo " /> <img src='" . str_replace('en_US', $button_localized, $button) . "' alt='" . $key . "' style='vertical-align: middle;' /></label><br /><br />\n";
|
294 |
-
}
|
295 |
|
296 |
-
|
297 |
-
|
298 |
-
|
|
|
|
|
|
|
|
|
299 |
?>
|
300 |
-
<input type="text" name="button_url" value="<?php echo $pd_options['button_url']; ?>" class="regular-text" /><br/>
|
301 |
-
<span class="setting-description"><?php _e( 'Enter a URL to a custom donation button.', 'paypal-donations' ) ?></span>
|
302 |
-
</fieldset>
|
303 |
-
</td>
|
304 |
-
</tr>
|
305 |
-
<tr valign="top">
|
306 |
-
<th scope="row"><label for="button_localized"><?php _e( 'Country and Language', 'paypal-donations' ) ?></label></th>
|
307 |
-
<td><select name="button_localized" id="button_localized">
|
308 |
-
<?php foreach ( $this->localized_buttons as $key => $localize ) {
|
309 |
-
echo '<option value="'.$key.'"';
|
310 |
-
if ($button_localized == $key) { echo ' selected="selected"'; }
|
311 |
-
echo '>'.$localize.'</option>';
|
312 |
-
}?></select>
|
313 |
-
<span class="setting-description"><br/><?php _e( 'Localize the language and the country for the button (Updated after saving the settings).', 'paypal-donations' ) ?></span></td>
|
314 |
-
</tr>
|
315 |
-
</table>
|
316 |
-
|
317 |
-
<p class="submit">
|
318 |
-
<input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Changes', 'paypal-donations' ) ?>" />
|
319 |
-
</p>
|
320 |
-
</div>
|
321 |
<?php
|
322 |
}
|
323 |
}
|
@@ -432,8 +348,104 @@ function paypal_donations_deinstall() {
|
|
432 |
delete_option('widget_paypal_donations');
|
433 |
}
|
434 |
|
435 |
-
|
436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
|
438 |
/**
|
439 |
* For backwards compability with earlier WordPress Versions
|
3 |
Plugin Name: PayPal Donations
|
4 |
Plugin URI: http://wpstorm.net/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.5
|
7 |
Author: Johan Steen
|
8 |
+
Author URI: http://johansteen.se/
|
9 |
Text Domain: paypal-donations
|
10 |
|
11 |
+
Copyright 2009-2012 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
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
+
class Paypal_Donations
|
29 |
+
{
|
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',
|
72 |
'en_US' => 'United States - U.S. English');
|
73 |
|
74 |
public function __construct() {
|
|
|
|
|
|
|
|
|
75 |
// Define the domain for translations
|
76 |
load_plugin_textdomain( 'paypal-donations', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
77 |
|
78 |
+
$this->init_hooks();
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
* Initializes the hooks for the plugin
|
83 |
*
|
84 |
+
* @return Nothing
|
85 |
*/
|
86 |
function init_hooks() {
|
87 |
add_action('admin_menu', array(&$this,'wp_admin'));
|
88 |
add_shortcode('paypal-donation', array(&$this,'paypal_shortcode'));
|
89 |
+
|
90 |
+
add_action( 'wp_head', array($this, 'add_css'), 999 );
|
91 |
+
|
92 |
global $wp_version;
|
93 |
if ( version_compare($wp_version, '2.8', '>=') )
|
94 |
add_action( 'widgets_init', array(&$this,'load_widget') );
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
+
* Adds inline CSS code to the head section of the html pages to center the
|
99 |
+
* PayPal button.
|
|
|
100 |
*/
|
101 |
+
function add_css()
|
102 |
+
{
|
103 |
+
$pd_options = get_option($this->plugin_options);
|
104 |
+
if ( isset($pd_options['center_button']) and $pd_options['center_button'] == true ) {
|
105 |
+
echo '<style type="text/css">'."\n";
|
106 |
+
echo '.paypal-donations { text-align: center !important }'."\n";
|
107 |
+
echo '</style>'."\n";
|
108 |
+
}
|
109 |
}
|
110 |
+
|
111 |
/**
|
112 |
* Register the Widget
|
113 |
*
|
177 |
// Get the button URL
|
178 |
if ( $pd_options['button'] != "custom" && !$button_url)
|
179 |
$button_url = str_replace('en_US', $button_localized, $this->donate_buttons[$pd_options['button']]);
|
|
|
180 |
$paypal_btn .= '<input type="image" src="' .$button_url. '" name="submit" alt="PayPal - The safer, easier way to pay online." />';
|
181 |
+
|
182 |
+
// PayPal stats tracking
|
183 |
+
if (!isset($pd_options['disable_stats']) or $pd_options['disable_stats'] != true)
|
184 |
+
$paypal_btn .= '<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />';
|
185 |
+
|
186 |
$paypal_btn .= '</div>';
|
187 |
$paypal_btn .= '</form>';
|
188 |
$paypal_btn .= "\n<!-- End PayPal Donations -->\n";
|
196 |
*/
|
197 |
function wp_admin() {
|
198 |
if (function_exists('add_options_page'))
|
199 |
+
add_options_page( 'PayPal Donations Options', 'PayPal Donations', 'administrator', basename(__FILE__), array(&$this, 'options_page') );
|
200 |
}
|
201 |
|
202 |
function admin_message($message) {
|
220 |
$pd_options['currency_code'] = trim( $_POST['currency_code'] );
|
221 |
$pd_options['amount'] = trim( $_POST['amount'] );
|
222 |
$pd_options['button_localized'] = trim( $_POST['button_localized'] );
|
223 |
+
$pd_options['disable_stats'] = isset($_POST['disable_stats']) ? true : false;
|
224 |
+
$pd_options['center_button'] = isset($_POST['center_button']) ? true : false;
|
225 |
update_option($this->plugin_options, $pd_options);
|
226 |
$this->admin_message( __( 'The PayPal Donations settings have been updated.', 'paypal-donations' ) );
|
227 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
+
|
230 |
+
// Render the settings screen
|
231 |
+
$settings = new Paypal_Donations_Settings();
|
232 |
+
$settings->set_options( get_option($this->plugin_options), $this->currency_codes, $this->donate_buttons, $this->localized_buttons);
|
233 |
+
$settings->render();
|
234 |
+
|
235 |
+
|
236 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
<?php
|
238 |
}
|
239 |
}
|
348 |
delete_option('widget_paypal_donations');
|
349 |
}
|
350 |
|
351 |
+
|
352 |
+
// -----------------------------------------------------------------------------
|
353 |
+
// Start the plugin
|
354 |
+
// -----------------------------------------------------------------------------
|
355 |
+
|
356 |
+
// Check the host environment
|
357 |
+
$paypal_donations_test_host = new Paypal_Donations_Host_Environment();
|
358 |
+
|
359 |
+
// If environment is up to date, start the plugin
|
360 |
+
if($paypal_donations_test_host->passed) {
|
361 |
+
// Load external classes
|
362 |
+
if (is_admin()) {
|
363 |
+
require plugin_dir_path(__FILE__).'classes/settings.php';
|
364 |
+
}
|
365 |
+
|
366 |
+
add_action(
|
367 |
+
'plugins_loaded',
|
368 |
+
create_function(
|
369 |
+
'',
|
370 |
+
'global $paypal_donations; $paypal_donations = new Paypal_Donations();'
|
371 |
+
)
|
372 |
+
);
|
373 |
+
}
|
374 |
+
|
375 |
+
|
376 |
+
/**
|
377 |
+
* PayPal Donations Host Environment.
|
378 |
+
*
|
379 |
+
* Checks that the host environment fulfils the requirements of Post Snippets.
|
380 |
+
* This class is designed to work with PHP versions below 5, to make sure it's
|
381 |
+
* always executed.
|
382 |
+
*
|
383 |
+
* @since PayPal Donations 1.5
|
384 |
+
*/
|
385 |
+
class Paypal_Donations_Host_Environment
|
386 |
+
{
|
387 |
+
// Minimum versions required
|
388 |
+
var $MIN_PHP_VERSION = '5';
|
389 |
+
var $MIN_WP_VERSION = '2.7';
|
390 |
+
var $PLUGIN_NAME = 'PayPal Donations';
|
391 |
+
var $passed = true;
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Constructor.
|
395 |
+
*
|
396 |
+
* Checks PHP and WordPress versions. If any check failes, a system notice
|
397 |
+
* is added and $passed is set to fail, which can be checked before trying
|
398 |
+
* to create the main class.
|
399 |
+
*/
|
400 |
+
function Paypal_Donations_Host_Environment()
|
401 |
+
{
|
402 |
+
// Check if PHP is too old
|
403 |
+
if (version_compare(PHP_VERSION, $this->MIN_PHP_VERSION, '<')) {
|
404 |
+
// Display notice
|
405 |
+
add_action( 'admin_notices', array(&$this, 'php_version_error') );
|
406 |
+
}
|
407 |
+
|
408 |
+
// Check if WordPress is too old
|
409 |
+
global $wp_version;
|
410 |
+
if ( version_compare($wp_version, $this->MIN_WP_VERSION, '<') ) {
|
411 |
+
add_action( 'admin_notices', array(&$this, 'wp_version_error') );
|
412 |
+
$this->passed = false;
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Displays a warning when installed on an old PHP version.
|
418 |
+
*/
|
419 |
+
function php_version_error() {
|
420 |
+
echo '<div class="error"><p><strong>';
|
421 |
+
printf( __(
|
422 |
+
'Error:<br/>
|
423 |
+
%1$s requires at least PHP version %2$s.
|
424 |
+
<br/>
|
425 |
+
Your installed PHP version: %3$s',
|
426 |
+
'post-snippets'),
|
427 |
+
$this->PLUGIN_NAME, $this->MIN_PHP_VERSION, PHP_VERSION);
|
428 |
+
echo '</strong></p></div>';
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Displays a warning when installed in an old Wordpress version.
|
433 |
+
*/
|
434 |
+
function wp_version_error() {
|
435 |
+
echo '<div class="error"><p><strong>';
|
436 |
+
printf( __(
|
437 |
+
'Error: %1$s requires WordPress Version %2$s or higher.',
|
438 |
+
'post-snippets'),
|
439 |
+
$this->PLUGIN_NAME, $this->MIN_WP_VERSION );
|
440 |
+
echo '</strong></p></div>';
|
441 |
+
}
|
442 |
+
}
|
443 |
+
|
444 |
+
|
445 |
+
|
446 |
+
// -----------------------------------------------------------------------------
|
447 |
+
// Helper functions
|
448 |
+
// -----------------------------------------------------------------------------
|
449 |
|
450 |
/**
|
451 |
* For backwards compability with earlier WordPress Versions
|
readme.txt
CHANGED
@@ -3,10 +3,10 @@ Contributors: artstorm
|
|
3 |
Donate link: http://wpstorm.net/wordpress-plugins/paypal-donations/#donation
|
4 |
Tags: paypal, donation, shortcode, widget, donate, button, sidebar
|
5 |
Requires at least: 2.7
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
-
Easy
|
10 |
|
11 |
== Description ==
|
12 |
|
@@ -61,65 +61,74 @@ Please visit [PayPal Donations' Comments](http://wpstorm.net/wordpress-plugins/p
|
|
61 |
== Changelog ==
|
62 |
|
63 |
|
64 |
-
= Version 1.
|
65 |
-
*
|
|
|
66 |
|
67 |
-
|
68 |
-
*
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
71 |
* Changed the plugin class name from paypal_donations to Paypal_Donations.
|
72 |
|
73 |
= Version 1.4.9.4 - 22 May 2011 =
|
74 |
-
* Included Norwegian translations by
|
75 |
|
76 |
= Version 1.4.9.3 - 18 Apr 2011 =
|
77 |
* Added Turkish Lira (TRY) to the list of currencies.
|
78 |
|
79 |
= Version 1.4.9.2 - 02 Apr 2011 =
|
80 |
-
* Added four new currencies that PayPal supports for donations to choose from:
|
|
|
|
|
81 |
|
82 |
= Version 1.4.9.1 - 08 Jan 2011 =
|
83 |
-
* Included Turkish translation by
|
84 |
|
85 |
= Version 1.4.9 - 08 Jul 2010 =
|
86 |
-
* Included Dutch translation by
|
87 |
|
88 |
= Version 1.4.8 - 29 Jun 2010 =
|
89 |
* Added shortcode for button_url.
|
90 |
* Removed a few deprecated functions from the code.
|
91 |
-
* Included German translation by
|
92 |
|
93 |
= Version 1.4.7 - 30 Apr 2010 =
|
94 |
-
* Included Spanish translation by
|
95 |
|
96 |
= Version 1.4.6 - 19 Feb 2010 =
|
97 |
-
* Included Italian translation by
|
98 |
* Updated the .pot file to include the latest strings for translations.
|
99 |
|
100 |
= Version 1.4.5 - 28 Nov 2009 =
|
101 |
-
* Added shortcode for the return_page
|
102 |
|
103 |
= Version 1.4.4 - 4 Nov 2009 =
|
104 |
-
* Included Hebrew translation by
|
105 |
|
106 |
= Version 1.4.3 - 15 Oct 2009 =
|
107 |
-
* Included Danish translation by
|
108 |
|
109 |
= Version 1.4.2 - 14 Oct 2009 =
|
110 |
-
* Included Albanian translation by
|
111 |
|
112 |
= Version 1.4.1 - 6 Sep 2009 =
|
113 |
* Corrected available language translations for the button graphics.
|
114 |
|
115 |
= Version 1.4 - 6 Sep 2009 =
|
116 |
-
* Added a dropdown menu to select country and language to localize the graphics
|
|
|
117 |
|
118 |
= Version 1.3.3 - 2 Sep 2009 =
|
119 |
-
* Included French translation by
|
120 |
|
121 |
= Version 1.3.2 - 28 Aug 2009 =
|
122 |
-
* Included Russian translation by
|
123 |
|
124 |
= Version 1.3.1 - 25 August 2009 =
|
125 |
* Added Swedish translation.
|
@@ -133,7 +142,8 @@ Please visit [PayPal Donations' Comments](http://wpstorm.net/wordpress-plugins/p
|
|
133 |
|
134 |
= Version 1.1 - 23 May 2009 =
|
135 |
* Added an option to select the currency to make the donations in.
|
136 |
-
* Changed the default button in a new install from a custom button to the large
|
|
|
137 |
|
138 |
= Version 1.0 - 7 May 2009 =
|
139 |
* Initial Release
|
3 |
Donate link: http://wpstorm.net/wordpress-plugins/paypal-donations/#donation
|
4 |
Tags: paypal, donation, shortcode, widget, donate, button, sidebar
|
5 |
Requires at least: 2.7
|
6 |
+
Tested up to: 3.3.1
|
7 |
+
Stable tag: 1.5
|
8 |
|
9 |
+
Easy, simple setup to add a PayPal Donation button as a Widget or with a shortcode.
|
10 |
|
11 |
== Description ==
|
12 |
|
61 |
== Changelog ==
|
62 |
|
63 |
|
64 |
+
= Version 1.5 - 9 Jan 2012 =
|
65 |
+
* Added an option to disable PayPal statistics tracking image.
|
66 |
+
* Added an option to center the button by overriding the theme CSS.
|
67 |
|
68 |
+
= Version 1.4.9.6 - 23 Oct 2011 =
|
69 |
+
* Included Malay – Bahasa Melayu translation by Amir Shariff.
|
70 |
+
|
71 |
+
= Version 1.4.9.5 - 3 Sep 2011 =
|
72 |
+
* Added filter 'paypal_donations_url', to hook into the URL used, to be able to
|
73 |
+
try the button against PayPal's Sandbox for instance.
|
74 |
+
* Added filter 'paypal_donations_amount', to hook into the set amount before
|
75 |
+
rendering the button.
|
76 |
+
* Included Lithuanian translation by Nata Strazda.
|
77 |
* Changed the plugin class name from paypal_donations to Paypal_Donations.
|
78 |
|
79 |
= Version 1.4.9.4 - 22 May 2011 =
|
80 |
+
* Included Norwegian translations by Tore Johnny Bråtveit.
|
81 |
|
82 |
= Version 1.4.9.3 - 18 Apr 2011 =
|
83 |
* Added Turkish Lira (TRY) to the list of currencies.
|
84 |
|
85 |
= Version 1.4.9.2 - 02 Apr 2011 =
|
86 |
+
* Added four new currencies that PayPal supports for donations to choose from:
|
87 |
+
Brazilian Real (BRL), Taiwan New Dollar (TWD), Philippine Peso (PHP), Thai
|
88 |
+
Baht (THB)
|
89 |
|
90 |
= Version 1.4.9.1 - 08 Jan 2011 =
|
91 |
+
* Included Turkish translation by Ersan Özdil.
|
92 |
|
93 |
= Version 1.4.9 - 08 Jul 2010 =
|
94 |
+
* Included Dutch translation by WP webshop.
|
95 |
|
96 |
= Version 1.4.8 - 29 Jun 2010 =
|
97 |
* Added shortcode for button_url.
|
98 |
* Removed a few deprecated functions from the code.
|
99 |
+
* Included German translation by Rian Kremer.
|
100 |
|
101 |
= Version 1.4.7 - 30 Apr 2010 =
|
102 |
+
* Included Spanish translation by Neoshinji.
|
103 |
|
104 |
= Version 1.4.6 - 19 Feb 2010 =
|
105 |
+
* Included Italian translation by Gianni Diurno.
|
106 |
* Updated the .pot file to include the latest strings for translations.
|
107 |
|
108 |
= Version 1.4.5 - 28 Nov 2009 =
|
109 |
+
* Added shortcode for the return_page.
|
110 |
|
111 |
= Version 1.4.4 - 4 Nov 2009 =
|
112 |
+
* Included Hebrew translation by Daniel Chcouri.
|
113 |
|
114 |
= Version 1.4.3 - 15 Oct 2009 =
|
115 |
+
* Included Danish translation by Georg S. Adamsen.
|
116 |
|
117 |
= Version 1.4.2 - 14 Oct 2009 =
|
118 |
+
* Included Albanian translation by Romeo Shuka.
|
119 |
|
120 |
= Version 1.4.1 - 6 Sep 2009 =
|
121 |
* Corrected available language translations for the button graphics.
|
122 |
|
123 |
= Version 1.4 - 6 Sep 2009 =
|
124 |
+
* Added a dropdown menu to select country and language to localize the graphics
|
125 |
+
of the donation button.
|
126 |
|
127 |
= Version 1.3.3 - 2 Sep 2009 =
|
128 |
+
* Included French translation by Thomas Cailhe (Oyabi).
|
129 |
|
130 |
= Version 1.3.2 - 28 Aug 2009 =
|
131 |
+
* Included Russian translation by FatCow.
|
132 |
|
133 |
= Version 1.3.1 - 25 August 2009 =
|
134 |
* Added Swedish translation.
|
142 |
|
143 |
= Version 1.1 - 23 May 2009 =
|
144 |
* Added an option to select the currency to make the donations in.
|
145 |
+
* Changed the default button in a new install from a custom button to the large
|
146 |
+
button.
|
147 |
|
148 |
= Version 1.0 - 7 May 2009 =
|
149 |
* Initial Release
|