Version Description
Download this release
Release Info
Developer | artstorm |
Plugin | PayPal Donations |
Version | 1.7 |
Comparing to | |
See all releases |
Code changes from version 1.6 to 1.7
- classes/settings.php +0 -195
- {languages → lang}/paypal-donations-da_DK.mo +0 -0
- {languages → lang}/paypal-donations-da_DK.po +0 -0
- {languages → lang}/paypal-donations-de_DE.mo +0 -0
- {languages → lang}/paypal-donations-de_DE.po +0 -0
- {languages → lang}/paypal-donations-es_ES.mo +0 -0
- {languages → lang}/paypal-donations-es_ES.po +0 -0
- {languages → lang}/paypal-donations-fr_FR.mo +0 -0
- {languages → lang}/paypal-donations-fr_FR.po +0 -0
- {languages → lang}/paypal-donations-he_IL.mo +0 -0
- {languages → lang}/paypal-donations-he_IL.po +0 -0
- {languages → lang}/paypal-donations-it_IT.mo +0 -0
- {languages → lang}/paypal-donations-it_IT.po +0 -0
- {languages → lang}/paypal-donations-lt_LT.mo +0 -0
- {languages → lang}/paypal-donations-lt_LT.po +0 -0
- {languages → lang}/paypal-donations-ms_MY.mo +0 -0
- {languages → lang}/paypal-donations-ms_MY.po +0 -0
- {languages → lang}/paypal-donations-nb_NO.mo +0 -0
- {languages → lang}/paypal-donations-nb_NO.po +0 -0
- {languages → lang}/paypal-donations-nl_NL.mo +0 -0
- {languages → lang}/paypal-donations-nl_NL.po +0 -0
- {languages → lang}/paypal-donations-nn_NO.mo +0 -0
- {languages → lang}/paypal-donations-nn_NO.po +0 -0
- {languages → lang}/paypal-donations-ro_RO.mo +0 -0
- {languages → lang}/paypal-donations-ro_RO.po +0 -0
- {languages → lang}/paypal-donations-ru_RU.mo +0 -0
- {languages → lang}/paypal-donations-ru_RU.po +0 -0
- {languages → lang}/paypal-donations-sq_AL.mo +0 -0
- {languages → lang}/paypal-donations-sq_AL.po +0 -0
- {languages → lang}/paypal-donations-sv_SE.mo +0 -0
- {languages → lang}/paypal-donations-sv_SE.po +0 -0
- {languages → lang}/paypal-donations-tr_TR.mo +0 -0
- {languages → lang}/paypal-donations-tr_TR.po +0 -0
- {languages → lang}/paypal-donations.pot +0 -0
- lib/PayPalDonations/Admin.php +68 -0
- lib/PayPalDonations/View.php +29 -0
- lib/PayPalDonations/Widget.php +108 -0
- paypal-donations.php +390 -488
- phpunit.xml +12 -0
- readme.txt +164 -153
- tests/PayPalDonationsTest.php +20 -0
- tests/bootstrap.php +8 -0
- views/admin.php +137 -0
- views/paypal-button.php +45 -0
- views/widget-form.php +23 -0
classes/settings.php
DELETED
@@ -1,195 +0,0 @@
|
|
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 |
-
private $checkout_languages;
|
19 |
-
|
20 |
-
public function set_options( $options, $code, $buttons, $loc_buttons, $checkout_lng )
|
21 |
-
{
|
22 |
-
$this->plugin_options = $options;
|
23 |
-
$this->currency_codes = $code;
|
24 |
-
$this->donate_buttons = $buttons;
|
25 |
-
$this->localized_buttons = $loc_buttons;
|
26 |
-
$this->checkout_languages = $checkout_lng;
|
27 |
-
}
|
28 |
-
|
29 |
-
public function render()
|
30 |
-
{
|
31 |
-
?>
|
32 |
-
<div class=wrap>
|
33 |
-
<h2>PayPal Donations</h2>
|
34 |
-
|
35 |
-
<form method="post" action="">
|
36 |
-
<?php wp_nonce_field('update-options'); ?>
|
37 |
-
<?php // $pd_options = get_option($this->plugin_options);
|
38 |
-
$pd_options = $this->plugin_options;
|
39 |
-
?>
|
40 |
-
<table class="form-table">
|
41 |
-
<tr valign="top">
|
42 |
-
<th scope="row"><label for="paypal_account"><?php _e( 'PayPal Account', 'paypal-donations' ) ?></label></th>
|
43 |
-
<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>
|
44 |
-
</tr>
|
45 |
-
<tr valign="top">
|
46 |
-
<th scope="row"><label for="currency_code"><?php _e( 'Currency', 'paypal-donations' ) ?></label></th>
|
47 |
-
<td><select name="currency_code" id="currency_code">
|
48 |
-
<?php if (isset($pd_options['currency_code'])) { $current_currency = $pd_options['currency_code']; } else { $current_currency = 'USD'; }
|
49 |
-
foreach ( $this->currency_codes as $key => $code ) {
|
50 |
-
echo '<option value="'.$key.'"';
|
51 |
-
if ($current_currency == $key) { echo ' selected="selected"'; }
|
52 |
-
echo '>'.$code.'</option>';
|
53 |
-
}?></select>
|
54 |
-
<span class="setting-description"><br/><?php _e( 'The currency to use for the donations.', 'paypal-donations' ) ?></span></td>
|
55 |
-
</tr>
|
56 |
-
</table>
|
57 |
-
|
58 |
-
<h3><?php _e( 'Optional Settings', 'paypal-donations' ) ?></h3>
|
59 |
-
<table class="form-table">
|
60 |
-
<tr valign="top">
|
61 |
-
<th scope="row"><label for="page_style"><?php _e( 'Page Style', 'paypal-donations' ) ?></label></th>
|
62 |
-
<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>
|
63 |
-
</tr>
|
64 |
-
<tr valign="top">
|
65 |
-
<th scope="row"><label for="return_page"><?php _e( 'Return Page', 'paypal-donations' ) ?></label></th>
|
66 |
-
<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>
|
67 |
-
</tr>
|
68 |
-
</table>
|
69 |
-
|
70 |
-
<h3><?php _e( 'Defaults', 'paypal-donations' ) ?></h3>
|
71 |
-
<table class="form-table">
|
72 |
-
<tr valign="top">
|
73 |
-
<th scope="row"><label for="amount"><?php _e( 'Amount', 'paypal-donations' ) ?></label></th>
|
74 |
-
<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>
|
75 |
-
</tr>
|
76 |
-
<tr valign="top">
|
77 |
-
<th scope="row"><label for="purpose"><?php _e( 'Purpose', 'paypal-donations' ) ?></label></th>
|
78 |
-
<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>
|
79 |
-
</tr>
|
80 |
-
<tr valign="top">
|
81 |
-
<th scope="row"><label for="reference"><?php _e( 'Reference', 'paypal-donations' ) ?></label></th>
|
82 |
-
<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>
|
83 |
-
</tr>
|
84 |
-
</table>
|
85 |
-
|
86 |
-
<h3><?php _e( 'Donation Button', 'paypal-donations' ) ?></h3>
|
87 |
-
<table class="form-table">
|
88 |
-
<tr>
|
89 |
-
<th scope="row"><?php _e( 'Select Button', 'paypal-donations' ) ?></th>
|
90 |
-
<td>
|
91 |
-
<fieldset><legend class="hidden">PayPal Button</legend>
|
92 |
-
<?php
|
93 |
-
$custom = TRUE;
|
94 |
-
if (isset($pd_options['button_localized'])) { $button_localized = $pd_options['button_localized']; } else { $button_localized = 'en_US'; }
|
95 |
-
if (isset($pd_options['button'])) { $current_button = $pd_options['button']; } else { $current_button = 'large'; }
|
96 |
-
foreach ( $this->donate_buttons as $key => $button ) {
|
97 |
-
echo "\t<label title='" . esc_attr($key) . "'><input style='padding: 10px 0 10px 0;' type='radio' name='button' value='" . esc_attr($key) . "'";
|
98 |
-
if ( $current_button === $key ) { // checked() uses "==" rather than "==="
|
99 |
-
echo " checked='checked'";
|
100 |
-
$custom = FALSE;
|
101 |
-
}
|
102 |
-
echo " /> <img src='" . str_replace('en_US', $button_localized, $button) . "' alt='" . $key . "' style='vertical-align: middle;' /></label><br /><br />\n";
|
103 |
-
}
|
104 |
-
|
105 |
-
echo ' <label><input type="radio" name="button" value="custom"';
|
106 |
-
checked( $custom, TRUE );
|
107 |
-
echo '/> ' . __('Custom Button:', 'paypal-donations') . ' </label>';
|
108 |
-
?>
|
109 |
-
<input type="text" name="button_url" value="<?php echo $pd_options['button_url']; ?>" class="regular-text" /><br/>
|
110 |
-
<span class="setting-description"><?php _e( 'Enter a URL to a custom donation button.', 'paypal-donations' ) ?></span>
|
111 |
-
</fieldset>
|
112 |
-
</td>
|
113 |
-
</tr>
|
114 |
-
<tr valign="top">
|
115 |
-
<th scope="row"><label for="button_localized"><?php _e( 'Country and Language', 'paypal-donations' ) ?></label></th>
|
116 |
-
<td><select name="button_localized" id="button_localized">
|
117 |
-
<?php foreach ( $this->localized_buttons as $key => $localize ) {
|
118 |
-
echo '<option value="'.$key.'"';
|
119 |
-
if ($button_localized == $key) { echo ' selected="selected"'; }
|
120 |
-
echo '>'.$localize.'</option>';
|
121 |
-
}?></select>
|
122 |
-
<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>
|
123 |
-
</tr>
|
124 |
-
</table>
|
125 |
-
|
126 |
-
<?php
|
127 |
-
// Extras
|
128 |
-
?>
|
129 |
-
<h3><?php _e( 'Extras', 'paypal-donations' ) ?></h3>
|
130 |
-
<p>Optional extra settings to fine tune the setup in certain scenarios.</p>
|
131 |
-
<?php
|
132 |
-
$this->checkbox(
|
133 |
-
__('Disable PayPal Statistics', 'paypal-donations'),
|
134 |
-
'disable_stats',
|
135 |
-
$pd_options['disable_stats']);
|
136 |
-
echo '<br/>';
|
137 |
-
|
138 |
-
$this->checkbox(
|
139 |
-
__('Theme CSS Override: Center Button', 'paypal-donations'),
|
140 |
-
'center_button',
|
141 |
-
$pd_options['center_button']);
|
142 |
-
echo '<br/>';
|
143 |
-
|
144 |
-
$this->checkbox(
|
145 |
-
__('Set Checkout Language:', 'paypal-donations'),
|
146 |
-
'set_checkout_language',
|
147 |
-
isset($pd_options['set_checkout_language']) ? $pd_options['set_checkout_language'] : false);
|
148 |
-
?>
|
149 |
-
|
150 |
-
<?php
|
151 |
-
if (isset($pd_options['checkout_language'])) { $checkout_language = $pd_options['checkout_language']; } else { $checkout_language = ''; }
|
152 |
-
?>
|
153 |
-
<select name="checkout_language" id="checkout_language">
|
154 |
-
<option value="">None</option>
|
155 |
-
<?php
|
156 |
-
foreach ( $this->checkout_languages as $key => $language ) {
|
157 |
-
echo '<option value="'.$key.'"';
|
158 |
-
if ($checkout_language == $key) { echo ' selected="selected"'; }
|
159 |
-
echo '>'.$language.'</option>';
|
160 |
-
}?>
|
161 |
-
</select>
|
162 |
-
<br/>
|
163 |
-
|
164 |
-
|
165 |
-
<p class="submit">
|
166 |
-
<input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Changes', 'paypal-donations' ) ?>" />
|
167 |
-
</p>
|
168 |
-
</div>
|
169 |
-
|
170 |
-
|
171 |
-
<?php
|
172 |
-
}
|
173 |
-
|
174 |
-
// -------------------------------------------------------------------------
|
175 |
-
// HTML and Form element methods
|
176 |
-
// -------------------------------------------------------------------------
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Checkbox.
|
180 |
-
* Renders the HTML for an input checkbox.
|
181 |
-
*
|
182 |
-
* @param string $label The label rendered to screen
|
183 |
-
* @param string $name The unique name to identify the input
|
184 |
-
* @param boolean $checked If the input is checked or not
|
185 |
-
*/
|
186 |
-
private function checkbox( $label, $name, $checked )
|
187 |
-
{
|
188 |
-
printf( '<input type="checkbox" name="%s" value="true"', $name );
|
189 |
-
if ($checked)
|
190 |
-
echo ' checked';
|
191 |
-
echo ' />';
|
192 |
-
echo ' '.$label;
|
193 |
-
}
|
194 |
-
|
195 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{languages → lang}/paypal-donations-da_DK.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-da_DK.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-de_DE.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-de_DE.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-es_ES.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-es_ES.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-fr_FR.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-fr_FR.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-he_IL.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-he_IL.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-it_IT.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-it_IT.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-lt_LT.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-lt_LT.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-ms_MY.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-ms_MY.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-nb_NO.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-nb_NO.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-nl_NL.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-nl_NL.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-nn_NO.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-nn_NO.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-ro_RO.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-ro_RO.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-ru_RU.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-ru_RU.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-sq_AL.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-sq_AL.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-sv_SE.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-sv_SE.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations-tr_TR.mo
RENAMED
File without changes
|
{languages → lang}/paypal-donations-tr_TR.po
RENAMED
File without changes
|
{languages → lang}/paypal-donations.pot
RENAMED
File without changes
|
lib/PayPalDonations/Admin.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 PayPalDonations_Admin
|
13 |
+
{
|
14 |
+
private $plugin_options;
|
15 |
+
private $currency_codes;
|
16 |
+
private $donate_buttons;
|
17 |
+
private $localized_buttons;
|
18 |
+
private $checkout_languages;
|
19 |
+
|
20 |
+
public function setOptions(
|
21 |
+
$options,
|
22 |
+
$code,
|
23 |
+
$buttons,
|
24 |
+
$loc_buttons,
|
25 |
+
$checkout_lng
|
26 |
+
) {
|
27 |
+
$this->plugin_options = $options;
|
28 |
+
$this->currency_codes = $code;
|
29 |
+
$this->donate_buttons = $buttons;
|
30 |
+
$this->localized_buttons = $loc_buttons;
|
31 |
+
$this->checkout_languages = $checkout_lng;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function render()
|
35 |
+
{
|
36 |
+
$data = array(
|
37 |
+
'plugin_options' => $this->plugin_options,
|
38 |
+
'currency_codes' => $this->currency_codes,
|
39 |
+
'donate_buttons' => $this->donate_buttons,
|
40 |
+
'localized_buttons' => $this->localized_buttons,
|
41 |
+
'checkout_languages' => $this->checkout_languages,
|
42 |
+
);
|
43 |
+
echo PayPalDonations_View::render(
|
44 |
+
plugin_dir_path(__FILE__).'../../views/admin.php', $data);
|
45 |
+
}
|
46 |
+
|
47 |
+
// -------------------------------------------------------------------------
|
48 |
+
// HTML and Form element methods
|
49 |
+
// -------------------------------------------------------------------------
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Checkbox.
|
53 |
+
* Renders the HTML for an input checkbox.
|
54 |
+
*
|
55 |
+
* @param string $label The label rendered to screen
|
56 |
+
* @param string $name The unique name to identify the input
|
57 |
+
* @param boolean $checked If the input is checked or not
|
58 |
+
*/
|
59 |
+
public static function checkbox($label, $name, $checked)
|
60 |
+
{
|
61 |
+
printf( '<input type="checkbox" name="%s" value="true"', $name );
|
62 |
+
if ($checked) {
|
63 |
+
echo ' checked';
|
64 |
+
}
|
65 |
+
echo ' />';
|
66 |
+
echo ' '.$label;
|
67 |
+
}
|
68 |
+
}
|
lib/PayPalDonations/View.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class for MVC like View Handling in WordPress.
|
4 |
+
*
|
5 |
+
* @package PayPal Donations
|
6 |
+
* @author Johan Steen <artstorm at gmail dot com>
|
7 |
+
*/
|
8 |
+
class PayPalDonations_View
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Render a View.
|
12 |
+
*
|
13 |
+
* @param string $filePath Include path to the template.
|
14 |
+
* @param array $data Data to be used within the template.
|
15 |
+
* @return string Returns the completed view.
|
16 |
+
*/
|
17 |
+
public static function render($filePath, $data = null)
|
18 |
+
{
|
19 |
+
// Check for data
|
20 |
+
($data) ? extract($data) : null;
|
21 |
+
|
22 |
+
ob_start();
|
23 |
+
include ($filePath);
|
24 |
+
$template = ob_get_contents();
|
25 |
+
ob_end_clean();
|
26 |
+
|
27 |
+
return $template;
|
28 |
+
}
|
29 |
+
}
|
lib/PayPalDonations/Widget.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Class for the Widget.
|
4 |
+
*
|
5 |
+
* @package PayPal Donations
|
6 |
+
* @author Johan Steen <artstorm at gmail dot com>
|
7 |
+
*/
|
8 |
+
class PayPalDonations_Widget extends WP_Widget
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Register the Widget.
|
12 |
+
*/
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
$widget_ops = array(
|
16 |
+
'classname' => 'widget_paypal_donations',
|
17 |
+
'description' => __('PayPal Donation Button', 'paypal-donations')
|
18 |
+
);
|
19 |
+
parent::__construct('paypal_donations', 'PayPal Donations', $widget_ops);
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Front-end display of widget.
|
24 |
+
*
|
25 |
+
* @see WP_Widget::widget()
|
26 |
+
*
|
27 |
+
* @param array $args Widget arguments.
|
28 |
+
* @param array $instance Saved values from database.
|
29 |
+
*/
|
30 |
+
public function widget($args, $instance)
|
31 |
+
{
|
32 |
+
extract($args);
|
33 |
+
// global $paypal_donations;
|
34 |
+
$paypal_donations = PayPalDonations::getInstance();
|
35 |
+
|
36 |
+
// Get the settings
|
37 |
+
$title = apply_filters('widget_title', $instance['title'] );
|
38 |
+
$text = $instance['text'];
|
39 |
+
$purpose = $instance['purpose'];
|
40 |
+
$reference = $instance['reference'];
|
41 |
+
|
42 |
+
echo $before_widget;
|
43 |
+
if ($title) {
|
44 |
+
echo $before_title . $title . $after_title;
|
45 |
+
}
|
46 |
+
if ($text) {
|
47 |
+
echo wpautop( $text );
|
48 |
+
}
|
49 |
+
echo $paypal_donations->generateHtml( $purpose, $reference );
|
50 |
+
echo $after_widget;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Sanitize widget form values as they are saved.
|
55 |
+
*
|
56 |
+
* @see WP_Widget::update()
|
57 |
+
*
|
58 |
+
* @param array $new_instance Values just sent to be saved.
|
59 |
+
* @param array $old_instance Previously saved values from database.
|
60 |
+
*
|
61 |
+
* @return array Updated safe values to be saved.
|
62 |
+
*/
|
63 |
+
public function update($new_instance, $old_instance)
|
64 |
+
{
|
65 |
+
$instance = $old_instance;
|
66 |
+
|
67 |
+
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
|
68 |
+
$instance['text'] = $new_instance['text'];
|
69 |
+
$instance['purpose'] = strip_tags(stripslashes($new_instance['purpose']));
|
70 |
+
$instance['reference'] = strip_tags(stripslashes($new_instance['reference']));
|
71 |
+
|
72 |
+
return $instance;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Back-end widget form.
|
77 |
+
*
|
78 |
+
* @see WP_Widget::form()
|
79 |
+
*
|
80 |
+
* @param array $instance Previously saved values from database.
|
81 |
+
*/
|
82 |
+
public function form($instance)
|
83 |
+
{
|
84 |
+
// Default Widget Settings
|
85 |
+
$defaults = array(
|
86 |
+
'title' => __('Donate', 'paypal-donations'),
|
87 |
+
'text' => '', 'purpose' => '',
|
88 |
+
'reference' => ''
|
89 |
+
);
|
90 |
+
$instance = wp_parse_args( (array) $instance, $defaults );
|
91 |
+
|
92 |
+
$data = array(
|
93 |
+
'instance' => $instance,
|
94 |
+
'title_id' => $this->get_field_id('title'),
|
95 |
+
'title_name' => $this->get_field_name('title'),
|
96 |
+
'text_id' => $this->get_field_id('text'),
|
97 |
+
'text_name' => $this->get_field_name('text'),
|
98 |
+
'purpose_id' => $this->get_field_id('purpose'),
|
99 |
+
'purpose_name' => $this->get_field_name('purpose'),
|
100 |
+
'reference_id' => $this->get_field_id('reference'),
|
101 |
+
'reference_name' => $this->get_field_name('reference'),
|
102 |
+
);
|
103 |
+
echo PayPalDonations_View::render(
|
104 |
+
plugin_dir_path(__FILE__).'../../views/widget-form.php',
|
105 |
+
$data
|
106 |
+
);
|
107 |
+
}
|
108 |
+
}
|
paypal-donations.php
CHANGED
@@ -1,488 +1,390 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
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 |
-
|
7 |
-
Author:
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
<
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
if (is_admin()) {
|
392 |
-
require plugin_dir_path(__FILE__).'classes/settings.php';
|
393 |
-
}
|
394 |
-
|
395 |
-
add_action(
|
396 |
-
'plugins_loaded',
|
397 |
-
create_function(
|
398 |
-
'',
|
399 |
-
'global $paypal_donations; $paypal_donations = new Paypal_Donations();'
|
400 |
-
)
|
401 |
-
);
|
402 |
-
}
|
403 |
-
|
404 |
-
|
405 |
-
/**
|
406 |
-
* PayPal Donations Host Environment.
|
407 |
-
*
|
408 |
-
* Checks that the host environment fulfils the requirements of Post Snippets.
|
409 |
-
* This class is designed to work with PHP versions below 5, to make sure it's
|
410 |
-
* always executed.
|
411 |
-
*
|
412 |
-
* @since PayPal Donations 1.5
|
413 |
-
*/
|
414 |
-
class Paypal_Donations_Host_Environment
|
415 |
-
{
|
416 |
-
// Minimum versions required
|
417 |
-
var $MIN_PHP_VERSION = '5';
|
418 |
-
var $MIN_WP_VERSION = '2.7';
|
419 |
-
var $PLUGIN_NAME = 'PayPal Donations';
|
420 |
-
var $passed = true;
|
421 |
-
|
422 |
-
/**
|
423 |
-
* Constructor.
|
424 |
-
*
|
425 |
-
* Checks PHP and WordPress versions. If any check failes, a system notice
|
426 |
-
* is added and $passed is set to fail, which can be checked before trying
|
427 |
-
* to create the main class.
|
428 |
-
*/
|
429 |
-
function Paypal_Donations_Host_Environment()
|
430 |
-
{
|
431 |
-
// Check if PHP is too old
|
432 |
-
if (version_compare(PHP_VERSION, $this->MIN_PHP_VERSION, '<')) {
|
433 |
-
// Display notice
|
434 |
-
add_action( 'admin_notices', array(&$this, 'php_version_error') );
|
435 |
-
$this->passed = false;
|
436 |
-
}
|
437 |
-
|
438 |
-
// Check if WordPress is too old
|
439 |
-
global $wp_version;
|
440 |
-
if ( version_compare($wp_version, $this->MIN_WP_VERSION, '<') ) {
|
441 |
-
add_action( 'admin_notices', array(&$this, 'wp_version_error') );
|
442 |
-
$this->passed = false;
|
443 |
-
}
|
444 |
-
}
|
445 |
-
|
446 |
-
/**
|
447 |
-
* Displays a warning when installed on an old PHP version.
|
448 |
-
*/
|
449 |
-
function php_version_error() {
|
450 |
-
echo '<div class="error"><p><strong>';
|
451 |
-
printf(
|
452 |
-
'Error: PayPal Donations requires PHP version %1$s or greater.<br/>'.
|
453 |
-
'Your installed PHP version: %2$s',
|
454 |
-
$this->MIN_PHP_VERSION, PHP_VERSION);
|
455 |
-
echo '</strong></p></div>';
|
456 |
-
}
|
457 |
-
|
458 |
-
/**
|
459 |
-
* Displays a warning when installed in an old Wordpress version.
|
460 |
-
*/
|
461 |
-
function wp_version_error() {
|
462 |
-
echo '<div class="error"><p><strong>';
|
463 |
-
printf(
|
464 |
-
'Error: PayPal Donations requires WordPress version %s or greater.',
|
465 |
-
$this->MIN_WP_VERSION );
|
466 |
-
echo '</strong></p></div>';
|
467 |
-
}
|
468 |
-
}
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
// -----------------------------------------------------------------------------
|
473 |
-
// Helper functions
|
474 |
-
// -----------------------------------------------------------------------------
|
475 |
-
|
476 |
-
/**
|
477 |
-
* For backwards compability with earlier WordPress Versions
|
478 |
-
*
|
479 |
-
* @since PayPal Donations 1.4.8
|
480 |
-
*/
|
481 |
-
|
482 |
-
# esc_attr isn't available in WordPress < 2.8.
|
483 |
-
if (!function_exists('esc_attr')) :
|
484 |
-
function esc_attr($arg) {
|
485 |
-
return attribute_escape($arg);
|
486 |
-
}
|
487 |
-
endif;
|
488 |
-
?>
|
1 |
+
<?php
|
2 |
+
/*
|
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 |
+
Author: Johan Steen
|
7 |
+
Author URI: http://johansteen.se/
|
8 |
+
Version: 1.7
|
9 |
+
License: GPLv2 or later
|
10 |
+
Text Domain: paypal-donations
|
11 |
+
|
12 |
+
Copyright 2009-2013 Johan Steen (email : artstorm [at] gmail [dot] com)
|
13 |
+
|
14 |
+
This program is free software; you can redistribute it and/or modify
|
15 |
+
it under the terms of the GNU General Public License as published by
|
16 |
+
the Free Software Foundation; either version 2 of the License, or
|
17 |
+
(at your option) any later version.
|
18 |
+
|
19 |
+
This program is distributed in the hope that it will be useful,
|
20 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
+
GNU General Public License for more details.
|
23 |
+
|
24 |
+
You should have received a copy of the GNU General Public License
|
25 |
+
along with this program; if not, write to the Free Software
|
26 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
+
*/
|
28 |
+
|
29 |
+
/** Load all of the necessary class files for the plugin */
|
30 |
+
spl_autoload_register('PayPalDonations::autoload');
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Init Singleton Class for PayPal Donations.
|
34 |
+
*
|
35 |
+
* @package PayPal Donations
|
36 |
+
* @author Johan Steen <artstorm at gmail dot com>
|
37 |
+
*/
|
38 |
+
class PayPalDonations
|
39 |
+
{
|
40 |
+
private static $instance = false;
|
41 |
+
|
42 |
+
const MIN_PHP_VERSION = '5.2.4';
|
43 |
+
const MIN_WP_VERSION = '2.8';
|
44 |
+
const OPTION_DB_KEY = 'paypal_donations_options';
|
45 |
+
|
46 |
+
|
47 |
+
// -------------------------------------------------------------------------
|
48 |
+
// Define constant variables and data arrays
|
49 |
+
// -------------------------------------------------------------------------
|
50 |
+
private $donate_buttons = array(
|
51 |
+
'small' => 'https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif',
|
52 |
+
'large' => 'https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif',
|
53 |
+
'cards' => 'https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif'
|
54 |
+
);
|
55 |
+
private $currency_codes = array(
|
56 |
+
'AUD' => 'Australian Dollars (A $)',
|
57 |
+
'CAD' => 'Canadian Dollars (C $)',
|
58 |
+
'EUR' => 'Euros (€)',
|
59 |
+
'GBP' => 'Pounds Sterling (£)',
|
60 |
+
'JPY' => 'Yen (¥)',
|
61 |
+
'USD' => 'U.S. Dollars ($)',
|
62 |
+
'NZD' => 'New Zealand Dollar ($)',
|
63 |
+
'CHF' => 'Swiss Franc',
|
64 |
+
'HKD' => 'Hong Kong Dollar ($)',
|
65 |
+
'SGD' => 'Singapore Dollar ($)',
|
66 |
+
'SEK' => 'Swedish Krona',
|
67 |
+
'DKK' => 'Danish Krone',
|
68 |
+
'PLN' => 'Polish Zloty',
|
69 |
+
'NOK' => 'Norwegian Krone',
|
70 |
+
'HUF' => 'Hungarian Forint',
|
71 |
+
'CZK' => 'Czech Koruna',
|
72 |
+
'ILS' => 'Israeli Shekel',
|
73 |
+
'MXN' => 'Mexican Peso',
|
74 |
+
'BRL' => 'Brazilian Real',
|
75 |
+
'TWD' => 'Taiwan New Dollar',
|
76 |
+
'PHP' => 'Philippine Peso',
|
77 |
+
'TRY' => 'Turkish Lira',
|
78 |
+
'THB' => 'Thai Baht'
|
79 |
+
);
|
80 |
+
private $localized_buttons = array(
|
81 |
+
'en_AU' => 'Australia - Australian English',
|
82 |
+
'de_DE/AT' => 'Austria - German',
|
83 |
+
'nl_NL/BE' => 'Belgium - Dutch',
|
84 |
+
'fr_XC' => 'Canada - French',
|
85 |
+
'zh_XC' => 'China - Simplified Chinese',
|
86 |
+
'fr_FR/FR' => 'France - French',
|
87 |
+
'de_DE/DE' => 'Germany - German',
|
88 |
+
'it_IT/IT' => 'Italy - Italian',
|
89 |
+
'ja_JP/JP' => 'Japan - Japanese',
|
90 |
+
'es_XC' => 'Mexico - Spanish',
|
91 |
+
'nl_NL/NL' => 'Netherlands - Dutch',
|
92 |
+
'pl_PL/PL' => 'Poland - Polish',
|
93 |
+
'es_ES/ES' => 'Spain - Spanish',
|
94 |
+
'de_DE/CH' => 'Switzerland - German',
|
95 |
+
'fr_FR/CH' => 'Switzerland - French',
|
96 |
+
'en_US' => 'United States - U.S. English'
|
97 |
+
);
|
98 |
+
private $checkout_languages = array(
|
99 |
+
'AU' => 'Australia',
|
100 |
+
'AT' => 'Austria',
|
101 |
+
'BR' => 'Brazil',
|
102 |
+
'CA' => 'Canada',
|
103 |
+
'CN' => 'China',
|
104 |
+
'FR' => 'France',
|
105 |
+
'DE' => 'Germany',
|
106 |
+
'IT' => 'Italy',
|
107 |
+
'NL' => 'Netherlands',
|
108 |
+
'ES' => 'Spain',
|
109 |
+
'SE' => 'Sweden',
|
110 |
+
'GB' => 'United Kingdom',
|
111 |
+
'US' => 'United States',
|
112 |
+
);
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Singleton class
|
116 |
+
*/
|
117 |
+
public static function getInstance()
|
118 |
+
{
|
119 |
+
if (!self::$instance) {
|
120 |
+
self::$instance = new self();
|
121 |
+
}
|
122 |
+
return self::$instance;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Constructor
|
127 |
+
* Initializes the plugin by setting localization, filters, and
|
128 |
+
* administration functions.
|
129 |
+
*/
|
130 |
+
private function __construct()
|
131 |
+
{
|
132 |
+
if (!$this->testHost()) {
|
133 |
+
return;
|
134 |
+
}
|
135 |
+
|
136 |
+
// Load plugin text domain
|
137 |
+
add_action('init', array($this, 'pluginTextdomain'));
|
138 |
+
|
139 |
+
register_uninstall_hook(__FILE__, array(__CLASS__, 'uninstall'));
|
140 |
+
|
141 |
+
add_action('admin_menu', array(&$this,'wpAdmin'));
|
142 |
+
add_shortcode('paypal-donation', array(&$this,'paypalShortcode'));
|
143 |
+
add_action('wp_head', array($this, 'addCss'), 999);
|
144 |
+
|
145 |
+
add_action('widgets_init',
|
146 |
+
create_function('', 'register_widget("PayPalDonations_Widget");'));
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* PSR-0 compliant autoloader to load classes as needed.
|
151 |
+
*
|
152 |
+
* @since 1.7
|
153 |
+
* @param string $classname The name of the class
|
154 |
+
* @return null Return early if the class name does not start with the
|
155 |
+
* correct prefix
|
156 |
+
*/
|
157 |
+
public static function autoload($className)
|
158 |
+
{
|
159 |
+
if ('PayPalDonations' !== mb_substr($className, 0, 15)) {
|
160 |
+
return;
|
161 |
+
}
|
162 |
+
$className = ltrim($className, '\\');
|
163 |
+
$fileName = '';
|
164 |
+
$namespace = '';
|
165 |
+
if ($lastNsPos = strrpos($className, '\\')) {
|
166 |
+
$namespace = substr($className, 0, $lastNsPos);
|
167 |
+
$className = substr($className, $lastNsPos + 1);
|
168 |
+
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
|
169 |
+
$fileName .= DIRECTORY_SEPARATOR;
|
170 |
+
}
|
171 |
+
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, 'lib_'.$className);
|
172 |
+
$fileName .='.php';
|
173 |
+
|
174 |
+
require $fileName;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Loads the plugin text domain for translation
|
179 |
+
*/
|
180 |
+
public function pluginTextdomain()
|
181 |
+
{
|
182 |
+
$domain = 'paypal-donations';
|
183 |
+
$locale = apply_filters('plugin_locale', get_locale(), $domain);
|
184 |
+
load_textdomain(
|
185 |
+
$domain,
|
186 |
+
WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo'
|
187 |
+
);
|
188 |
+
load_plugin_textdomain(
|
189 |
+
$domain,
|
190 |
+
false,
|
191 |
+
dirname(plugin_basename(__FILE__)).'/lang/'
|
192 |
+
);
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Fired when the plugin is uninstalled.
|
197 |
+
*/
|
198 |
+
public function uninstall()
|
199 |
+
{
|
200 |
+
delete_option('paypal_donations_options');
|
201 |
+
delete_option('widget_paypal_donations');
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Adds inline CSS code to the head section of the html pages to center the
|
206 |
+
* PayPal button.
|
207 |
+
*/
|
208 |
+
public function addCss()
|
209 |
+
{
|
210 |
+
$opts = get_option(self::OPTION_DB_KEY);
|
211 |
+
if (isset($opts['center_button']) and $opts['center_button'] == true) {
|
212 |
+
echo '<style type="text/css">'."\n";
|
213 |
+
echo '.paypal-donations { text-align: center !important }'."\n";
|
214 |
+
echo '</style>'."\n";
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Create and register the PayPal shortcode
|
220 |
+
*/
|
221 |
+
public function paypalShortcode($atts)
|
222 |
+
{
|
223 |
+
extract(shortcode_atts(array(
|
224 |
+
'purpose' => '',
|
225 |
+
'reference' => '',
|
226 |
+
'amount' => '',
|
227 |
+
'return_page' => '',
|
228 |
+
'button_url' => '',
|
229 |
+
), $atts));
|
230 |
+
|
231 |
+
return $this->generateHtml(
|
232 |
+
$purpose,
|
233 |
+
$reference,
|
234 |
+
$amount,
|
235 |
+
$return_page,
|
236 |
+
$button_url
|
237 |
+
);
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Generate the PayPal button HTML code
|
242 |
+
*/
|
243 |
+
public function generateHtml(
|
244 |
+
$purpose = null,
|
245 |
+
$reference = null,
|
246 |
+
$amount = null,
|
247 |
+
$return_page = null,
|
248 |
+
$button_url = null
|
249 |
+
) {
|
250 |
+
$pd_options = get_option(self::OPTION_DB_KEY);
|
251 |
+
|
252 |
+
// Set overrides for purpose and reference if defined
|
253 |
+
$purpose = (!$purpose) ? $pd_options['purpose'] : $purpose;
|
254 |
+
$reference = (!$reference) ? $pd_options['reference'] : $reference;
|
255 |
+
$amount = (!$amount) ? $pd_options['amount'] : $amount;
|
256 |
+
$return_page = (!$return_page) ? $pd_options['return_page'] : $return_page;
|
257 |
+
$button_url = (!$button_url) ? $pd_options['button_url'] : $button_url;
|
258 |
+
|
259 |
+
$data = array(
|
260 |
+
'pd_options' => $pd_options,
|
261 |
+
'return_page' => $return_page,
|
262 |
+
'purpose' => $purpose,
|
263 |
+
'reference' => $reference,
|
264 |
+
'amount' => $amount,
|
265 |
+
'button_url' => $button_url,
|
266 |
+
'donate_buttons' => $this->donate_buttons,
|
267 |
+
);
|
268 |
+
|
269 |
+
return PayPalDonations_View::render(
|
270 |
+
plugin_dir_path(__FILE__).'views/paypal-button.php',
|
271 |
+
$data
|
272 |
+
);
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* The Admin Page and all it's functions
|
277 |
+
*/
|
278 |
+
public function wpAdmin()
|
279 |
+
{
|
280 |
+
if (function_exists('add_options_page'))
|
281 |
+
add_options_page(
|
282 |
+
'PayPal Donations Options',
|
283 |
+
'PayPal Donations',
|
284 |
+
'administrator',
|
285 |
+
basename(__FILE__),
|
286 |
+
array(&$this, 'optionsPage')
|
287 |
+
);
|
288 |
+
}
|
289 |
+
|
290 |
+
public function adminMessage($message)
|
291 |
+
{
|
292 |
+
if ($message) {
|
293 |
+
?>
|
294 |
+
<div class="updated"><p><strong>
|
295 |
+
<?php echo $message; ?>
|
296 |
+
</strong></p></div>
|
297 |
+
<?php
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
public function optionsPage()
|
302 |
+
{
|
303 |
+
// Update Options
|
304 |
+
if (isset($_POST['Submit'])) {
|
305 |
+
$pd_options['paypal_account'] = trim( $_POST['paypal_account'] );
|
306 |
+
$pd_options['page_style'] = trim( $_POST['page_style'] );
|
307 |
+
$pd_options['return_page'] = trim( $_POST['return_page'] );
|
308 |
+
$pd_options['purpose'] = trim( $_POST['purpose'] );
|
309 |
+
$pd_options['reference'] = trim( $_POST['reference'] );
|
310 |
+
$pd_options['button'] = trim( $_POST['button'] );
|
311 |
+
$pd_options['button_url'] = trim( $_POST['button_url'] );
|
312 |
+
$pd_options['currency_code'] = trim( $_POST['currency_code'] );
|
313 |
+
$pd_options['amount'] = trim( $_POST['amount'] );
|
314 |
+
$pd_options['button_localized'] = trim( $_POST['button_localized'] );
|
315 |
+
$pd_options['disable_stats'] = isset($_POST['disable_stats']) ? true : false;
|
316 |
+
$pd_options['center_button'] = isset($_POST['center_button']) ? true : false;
|
317 |
+
$pd_options['set_checkout_language'] = isset($_POST['set_checkout_language']) ? true : false;
|
318 |
+
$pd_options['checkout_language'] = trim( $_POST['checkout_language'] );
|
319 |
+
update_option(self::OPTION_DB_KEY, $pd_options);
|
320 |
+
$this->adminMessage( __( 'The PayPal Donations settings have been updated.', 'paypal-donations' ) );
|
321 |
+
}
|
322 |
+
|
323 |
+
// Render the settings screen
|
324 |
+
$settings = new PayPalDonations_Admin();
|
325 |
+
$settings->setOptions(
|
326 |
+
get_option(self::OPTION_DB_KEY),
|
327 |
+
$this->currency_codes,
|
328 |
+
$this->donate_buttons,
|
329 |
+
$this->localized_buttons,
|
330 |
+
$this->checkout_languages
|
331 |
+
);
|
332 |
+
$settings->render();
|
333 |
+
}
|
334 |
+
|
335 |
+
// -------------------------------------------------------------------------
|
336 |
+
// Environment Checks
|
337 |
+
// -------------------------------------------------------------------------
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Constructor.
|
341 |
+
*
|
342 |
+
* Checks PHP and WordPress versions. If any check failes, a system notice
|
343 |
+
* is added and $passed is set to fail, which can be checked before trying
|
344 |
+
* to create the main class.
|
345 |
+
*/
|
346 |
+
private function testHost()
|
347 |
+
{
|
348 |
+
// Check if PHP is too old
|
349 |
+
if (version_compare(PHP_VERSION, self::MIN_PHP_VERSION, '<')) {
|
350 |
+
// Display notice
|
351 |
+
add_action( 'admin_notices', array(&$this, 'phpVersionError') );
|
352 |
+
return false;
|
353 |
+
}
|
354 |
+
|
355 |
+
// Check if WordPress is too old
|
356 |
+
global $wp_version;
|
357 |
+
if (version_compare($wp_version, self::MIN_WP_VERSION, '<')) {
|
358 |
+
add_action( 'admin_notices', array(&$this, 'wpVersionError') );
|
359 |
+
return false;
|
360 |
+
}
|
361 |
+
return true;
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Displays a warning when installed on an old PHP version.
|
366 |
+
*/
|
367 |
+
public function phpVersionError()
|
368 |
+
{
|
369 |
+
echo '<div class="error"><p><strong>';
|
370 |
+
printf(
|
371 |
+
'Error: PayPal Donations requires PHP version %1$s or greater.<br/>'.
|
372 |
+
'Your installed PHP version: %2$s',
|
373 |
+
self::MIN_PHP_VERSION, PHP_VERSION);
|
374 |
+
echo '</strong></p></div>';
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Displays a warning when installed in an old Wordpress version.
|
379 |
+
*/
|
380 |
+
public function wpVersionError()
|
381 |
+
{
|
382 |
+
echo '<div class="error"><p><strong>';
|
383 |
+
printf(
|
384 |
+
'Error: PayPal Donations requires WordPress version %s or greater.',
|
385 |
+
self::MIN_WP_VERSION );
|
386 |
+
echo '</strong></p></div>';
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
add_action('plugins_loaded', array('PayPalDonations', 'getInstance'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
phpunit.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<phpunit
|
3 |
+
colors="true"
|
4 |
+
stopOnFailure="false"
|
5 |
+
bootstrap="tests/bootstrap.php">
|
6 |
+
backupGlobals="false"
|
7 |
+
<testsuites>
|
8 |
+
<testsuite name="complete">
|
9 |
+
<directory>tests</directory>
|
10 |
+
</testsuite>
|
11 |
+
</testsuites>
|
12 |
+
</phpunit>
|
readme.txt
CHANGED
@@ -1,153 +1,164 @@
|
|
1 |
-
|
2 |
-
Contributors: artstorm
|
3 |
-
Tags: paypal, donation, shortcode, widget, donate, button, sidebar
|
4 |
-
Requires at least: 2.
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 1.
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
==
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
*
|
70 |
-
*
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
*
|
81 |
-
*
|
82 |
-
|
83 |
-
= Version 1.4.9.
|
84 |
-
* Included
|
85 |
-
|
86 |
-
= Version 1.4.9.
|
87 |
-
* Added
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
= Version 1.4.9.
|
95 |
-
* Included
|
96 |
-
|
97 |
-
= Version 1.4.9 -
|
98 |
-
*
|
99 |
-
|
100 |
-
= Version 1.4.
|
101 |
-
* Added
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
= Version 1.4.
|
106 |
-
* Included
|
107 |
-
|
108 |
-
= Version 1.4.
|
109 |
-
* Included
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
*
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
* Added
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
*
|
150 |
-
|
151 |
-
|
152 |
-
= Version 1.
|
153 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== PayPal Donations ===
|
2 |
+
Contributors: artstorm
|
3 |
+
Tags: paypal, donation, shortcode, widget, donate, button, sidebar
|
4 |
+
Requires at least: 2.8
|
5 |
+
Tested up to: 3.5.1
|
6 |
+
Stable tag: 1.7
|
7 |
+
License: GPLv2 or later
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
|
10 |
+
Easy, simple setup to add a PayPal Donation button as a Widget or with a shortcode.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
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, localization of the button, custom payment page style and the return page.
|
15 |
+
|
16 |
+
= Widget =
|
17 |
+
|
18 |
+
In the Appearance -> Widgets 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.
|
19 |
+
|
20 |
+
= Shortcode =
|
21 |
+
|
22 |
+
Insert the button in your pages or posts with this shortcode
|
23 |
+
|
24 |
+
`[paypal-donation]`
|
25 |
+
|
26 |
+
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:
|
27 |
+
|
28 |
+
`[paypal-donation purpose="Spline Importer" reference="3D Plugins"]`
|
29 |
+
|
30 |
+
as an example.
|
31 |
+
|
32 |
+
This donation plugin generates valid XHTML Transitional and Strict code.
|
33 |
+
|
34 |
+
For complete usage instructions see: [PayPal Donations](http://wpstorm.net/wordpress-plugins/paypal-donations/ "Complete Usage Instructions for PayPal Donations")
|
35 |
+
|
36 |
+
See the [Changelog](http://wordpress.org/extend/plugins/paypal-donations/changelog/) for what's new. Available [Translations](http://wpstorm.net/wordpress-plugins/paypal-donations/#translations).
|
37 |
+
|
38 |
+
= Contribute =
|
39 |
+
|
40 |
+
The plugin is available on [GitHub](https://github.com/artstorm/paypal-donations), so developers feel free to fork the repository, make any updates and then send me a pull request.
|
41 |
+
|
42 |
+
== Installation ==
|
43 |
+
|
44 |
+
= Install =
|
45 |
+
|
46 |
+
1. Upload the 'paypal-donations' folder to the '/wp-content/plugins/' directory.
|
47 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
48 |
+
3. Go to Settings -> PayPal Donations and start entering your info.
|
49 |
+
|
50 |
+
= Uninstall =
|
51 |
+
|
52 |
+
1. Deactivate PayPal Donations in the 'Plugins' menu in Wordpress.
|
53 |
+
2. After Deactivation a 'Delete' link appears below the plugin name, follow the link and confim with 'Yes, Delete these files'.
|
54 |
+
3. This will delete all the plugin files from the server as well as erasing all options the plugin has stored in the database.
|
55 |
+
|
56 |
+
== Frequently Asked Questions ==
|
57 |
+
|
58 |
+
Please visit [PayPal Donations' Comments](http://wpstorm.net/wordpress-plugins/paypal-donations/#comments) for questions and answers.
|
59 |
+
|
60 |
+
== Screenshots ==
|
61 |
+
|
62 |
+
1. Admin page where you setup the plugin
|
63 |
+
1. Sidebar Widget Admin Options
|
64 |
+
|
65 |
+
== Changelog ==
|
66 |
+
|
67 |
+
= Version 1.7 - 19 feb 2013 =
|
68 |
+
* Moved the development to [GitHub](https://github.com/artstorm/paypal-donations).
|
69 |
+
* Refactored code to comply with the PSR-2 standard.
|
70 |
+
* Bumped miniumum PHP version to 5.2.4.
|
71 |
+
* Bumped minimum required WordPress version to WordPress 2.8.
|
72 |
+
|
73 |
+
= Version 1.6 - 13 Mar 2012 =
|
74 |
+
* Added an option under extras to set a PayPal checkout language.
|
75 |
+
* Added filter `paypal_donations_purpose_html`, to allow tweaking the default
|
76 |
+
hidden form input element for purpose.
|
77 |
+
* Included Romanian translation by Marko Pozner.
|
78 |
+
|
79 |
+
= Version 1.5 - 9 Jan 2012 =
|
80 |
+
* Added an option to disable PayPal statistics tracking image.
|
81 |
+
* Added an option to center the button by overriding the theme CSS.
|
82 |
+
|
83 |
+
= Version 1.4.9.6 - 23 Oct 2011 =
|
84 |
+
* Included Malay – Bahasa Melayu translation by Amir Shariff.
|
85 |
+
|
86 |
+
= Version 1.4.9.5 - 3 Sep 2011 =
|
87 |
+
* Added filter 'paypal_donations_url', to hook into the URL used, to be able to
|
88 |
+
try the button against PayPal's Sandbox for instance.
|
89 |
+
* Added filter 'paypal_donations_amount', to hook into the set amount before
|
90 |
+
rendering the button.
|
91 |
+
* Included Lithuanian translation by Nata Strazda.
|
92 |
+
* Changed the plugin class name from paypal_donations to Paypal_Donations.
|
93 |
+
|
94 |
+
= Version 1.4.9.4 - 22 May 2011 =
|
95 |
+
* Included Norwegian translations by Tore Johnny Bråtveit.
|
96 |
+
|
97 |
+
= Version 1.4.9.3 - 18 Apr 2011 =
|
98 |
+
* Added Turkish Lira (TRY) to the list of currencies.
|
99 |
+
|
100 |
+
= Version 1.4.9.2 - 02 Apr 2011 =
|
101 |
+
* Added four new currencies that PayPal supports for donations to choose from:
|
102 |
+
Brazilian Real (BRL), Taiwan New Dollar (TWD), Philippine Peso (PHP), Thai
|
103 |
+
Baht (THB)
|
104 |
+
|
105 |
+
= Version 1.4.9.1 - 08 Jan 2011 =
|
106 |
+
* Included Turkish translation by Ersan Özdil.
|
107 |
+
|
108 |
+
= Version 1.4.9 - 08 Jul 2010 =
|
109 |
+
* Included Dutch translation by WP webshop.
|
110 |
+
|
111 |
+
= Version 1.4.8 - 29 Jun 2010 =
|
112 |
+
* Added shortcode for button_url.
|
113 |
+
* Removed a few deprecated functions from the code.
|
114 |
+
* Included German translation by Rian Kremer.
|
115 |
+
|
116 |
+
= Version 1.4.7 - 30 Apr 2010 =
|
117 |
+
* Included Spanish translation by Neoshinji.
|
118 |
+
|
119 |
+
= Version 1.4.6 - 19 Feb 2010 =
|
120 |
+
* Included Italian translation by Gianni Diurno.
|
121 |
+
* Updated the .pot file to include the latest strings for translations.
|
122 |
+
|
123 |
+
= Version 1.4.5 - 28 Nov 2009 =
|
124 |
+
* Added shortcode for the return_page.
|
125 |
+
|
126 |
+
= Version 1.4.4 - 4 Nov 2009 =
|
127 |
+
* Included Hebrew translation by Daniel Chcouri.
|
128 |
+
|
129 |
+
= Version 1.4.3 - 15 Oct 2009 =
|
130 |
+
* Included Danish translation by Georg S. Adamsen.
|
131 |
+
|
132 |
+
= Version 1.4.2 - 14 Oct 2009 =
|
133 |
+
* Included Albanian translation by Romeo Shuka.
|
134 |
+
|
135 |
+
= Version 1.4.1 - 6 Sep 2009 =
|
136 |
+
* Corrected available language translations for the button graphics.
|
137 |
+
|
138 |
+
= Version 1.4 - 6 Sep 2009 =
|
139 |
+
* Added a dropdown menu to select country and language to localize the graphics
|
140 |
+
of the donation button.
|
141 |
+
|
142 |
+
= Version 1.3.3 - 2 Sep 2009 =
|
143 |
+
* Included French translation by Thomas Cailhe (Oyabi).
|
144 |
+
|
145 |
+
= Version 1.3.2 - 28 Aug 2009 =
|
146 |
+
* Included Russian translation by FatCow.
|
147 |
+
|
148 |
+
= Version 1.3.1 - 25 August 2009 =
|
149 |
+
* Added Swedish translation.
|
150 |
+
* Added the .pot file and textdomained all strings to allow translations.
|
151 |
+
|
152 |
+
= Version 1.3 - 8 July 2009 =
|
153 |
+
* Added an option to set a default donation amount.
|
154 |
+
|
155 |
+
= Version 1.2 - 18 June 2009 =
|
156 |
+
* Added a sidebar Widget (WordPress 2.8 or newer)
|
157 |
+
|
158 |
+
= Version 1.1 - 23 May 2009 =
|
159 |
+
* Added an option to select the currency to make the donations in.
|
160 |
+
* Changed the default button in a new install from a custom button to the large
|
161 |
+
button.
|
162 |
+
|
163 |
+
= Version 1.0 - 7 May 2009 =
|
164 |
+
* Initial Release
|
tests/PayPalDonationsTest.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PayPal Donations Unit Tests
|
4 |
+
*/
|
5 |
+
class PayPalDonationsTest extends WP_UnitTestCase {
|
6 |
+
|
7 |
+
private $plugin = 'paypal-donations';
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
}
|
12 |
+
|
13 |
+
// -------------------------------------------------------------------------
|
14 |
+
// Tests
|
15 |
+
// -------------------------------------------------------------------------
|
16 |
+
|
17 |
+
function testPluginInitialization() {
|
18 |
+
// $this->assertFalse( null == $this->plugin );
|
19 |
+
}
|
20 |
+
}
|
tests/bootstrap.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$GLOBALS['wp_tests_options'] = array(
|
3 |
+
'active_plugins' => array( 'paypal-donations/paypal-donations.php' ),
|
4 |
+
'template' => 'twentyeleven',
|
5 |
+
'stylesheet' => 'twentyeleven',
|
6 |
+
);
|
7 |
+
|
8 |
+
require_once('D:/Dropbox/Code/_Tools/UniformServer/www/wordpress.dev/wordpress-tests/bootstrap.php');
|
views/admin.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class=wrap>
|
2 |
+
<h2>PayPal Donations</h2>
|
3 |
+
<form method="post" action="">
|
4 |
+
<?php wp_nonce_field('update-options'); ?>
|
5 |
+
<?php // $pd_options = get_option($this->plugin_options);
|
6 |
+
$pd_options = $plugin_options;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<table class="form-table">
|
10 |
+
<tr valign="top">
|
11 |
+
<th scope="row"><label for="paypal_account"><?php _e( 'PayPal Account', 'paypal-donations' ) ?></label></th>
|
12 |
+
<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>
|
13 |
+
</tr>
|
14 |
+
<tr valign="top">
|
15 |
+
<th scope="row"><label for="currency_code"><?php _e( 'Currency', 'paypal-donations' ) ?></label></th>
|
16 |
+
<td><select name="currency_code" id="currency_code">
|
17 |
+
<?php if (isset($pd_options['currency_code'])) { $current_currency = $pd_options['currency_code']; } else { $current_currency = 'USD'; }
|
18 |
+
foreach ( $currency_codes as $key => $code ) {
|
19 |
+
echo '<option value="'.$key.'"';
|
20 |
+
if ($current_currency == $key) { echo ' selected="selected"'; }
|
21 |
+
echo '>'.$code.'</option>';
|
22 |
+
}?></select>
|
23 |
+
<span class="setting-description"><br/><?php _e( 'The currency to use for the donations.', 'paypal-donations' ) ?></span></td>
|
24 |
+
</tr>
|
25 |
+
</table>
|
26 |
+
|
27 |
+
<h3><?php _e( 'Optional Settings', 'paypal-donations' ) ?></h3>
|
28 |
+
<table class="form-table">
|
29 |
+
<tr valign="top">
|
30 |
+
<th scope="row"><label for="page_style"><?php _e( 'Page Style', 'paypal-donations' ) ?></label></th>
|
31 |
+
<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>
|
32 |
+
</tr>
|
33 |
+
<tr valign="top">
|
34 |
+
<th scope="row"><label for="return_page"><?php _e( 'Return Page', 'paypal-donations' ) ?></label></th>
|
35 |
+
<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>
|
36 |
+
</tr>
|
37 |
+
</table>
|
38 |
+
|
39 |
+
<h3><?php _e( 'Defaults', 'paypal-donations' ) ?></h3>
|
40 |
+
<table class="form-table">
|
41 |
+
<tr valign="top">
|
42 |
+
<th scope="row"><label for="amount"><?php _e( 'Amount', 'paypal-donations' ) ?></label></th>
|
43 |
+
<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>
|
44 |
+
</tr>
|
45 |
+
<tr valign="top">
|
46 |
+
<th scope="row"><label for="purpose"><?php _e( 'Purpose', 'paypal-donations' ) ?></label></th>
|
47 |
+
<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>
|
48 |
+
</tr>
|
49 |
+
<tr valign="top">
|
50 |
+
<th scope="row"><label for="reference"><?php _e( 'Reference', 'paypal-donations' ) ?></label></th>
|
51 |
+
<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>
|
52 |
+
</tr>
|
53 |
+
</table>
|
54 |
+
|
55 |
+
<h3><?php _e( 'Donation Button', 'paypal-donations' ) ?></h3>
|
56 |
+
<table class="form-table">
|
57 |
+
<tr>
|
58 |
+
<th scope="row"><?php _e( 'Select Button', 'paypal-donations' ) ?></th>
|
59 |
+
<td>
|
60 |
+
<fieldset><legend class="hidden">PayPal Button</legend>
|
61 |
+
<?php
|
62 |
+
$custom = true;
|
63 |
+
if (isset($pd_options['button_localized'])) { $button_localized = $pd_options['button_localized']; } else { $button_localized = 'en_US'; }
|
64 |
+
if (isset($pd_options['button'])) { $current_button = $pd_options['button']; } else { $current_button = 'large'; }
|
65 |
+
foreach ( $donate_buttons as $key => $button ) {
|
66 |
+
echo "\t<label title='" . esc_attr($key) . "'><input style='padding: 10px 0 10px 0;' type='radio' name='button' value='" . esc_attr($key) . "'";
|
67 |
+
if ( $current_button === $key ) { // checked() uses "==" rather than "==="
|
68 |
+
echo " checked='checked'";
|
69 |
+
$custom = false;
|
70 |
+
}
|
71 |
+
echo " /> <img src='" . str_replace('en_US', $button_localized, $button) . "' alt='" . $key . "' style='vertical-align: middle;' /></label><br /><br />\n";
|
72 |
+
}
|
73 |
+
|
74 |
+
echo ' <label><input type="radio" name="button" value="custom"';
|
75 |
+
checked( $custom, true );
|
76 |
+
echo '/> ' . __('Custom Button:', 'paypal-donations') . ' </label>';
|
77 |
+
?>
|
78 |
+
<input type="text" name="button_url" value="<?php echo $pd_options['button_url']; ?>" class="regular-text" /><br/>
|
79 |
+
<span class="setting-description"><?php _e( 'Enter a URL to a custom donation button.', 'paypal-donations' ) ?></span>
|
80 |
+
</fieldset>
|
81 |
+
</td>
|
82 |
+
</tr>
|
83 |
+
<tr valign="top">
|
84 |
+
<th scope="row"><label for="button_localized"><?php _e( 'Country and Language', 'paypal-donations' ) ?></label></th>
|
85 |
+
<td><select name="button_localized" id="button_localized">
|
86 |
+
<?php foreach ( $localized_buttons as $key => $localize ) {
|
87 |
+
echo '<option value="'.$key.'"';
|
88 |
+
if ($button_localized == $key) { echo ' selected="selected"'; }
|
89 |
+
echo '>'.$localize.'</option>';
|
90 |
+
}?></select>
|
91 |
+
<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>
|
92 |
+
</tr>
|
93 |
+
</table>
|
94 |
+
|
95 |
+
<?php
|
96 |
+
// Extras
|
97 |
+
?>
|
98 |
+
<h3><?php _e( 'Extras', 'paypal-donations' ) ?></h3>
|
99 |
+
<p>Optional extra settings to fine tune the setup in certain scenarios.</p>
|
100 |
+
<?php
|
101 |
+
PayPalDonations_Admin::checkbox(
|
102 |
+
__('Disable PayPal Statistics', 'paypal-donations'),
|
103 |
+
'disable_stats',
|
104 |
+
$pd_options['disable_stats']);
|
105 |
+
echo '<br/>';
|
106 |
+
|
107 |
+
PayPalDonations_Admin::checkbox(
|
108 |
+
__('Theme CSS Override: Center Button', 'paypal-donations'),
|
109 |
+
'center_button',
|
110 |
+
$pd_options['center_button']);
|
111 |
+
echo '<br/>';
|
112 |
+
|
113 |
+
PayPalDonations_Admin::checkbox(
|
114 |
+
__('Set Checkout Language:', 'paypal-donations'),
|
115 |
+
'set_checkout_language',
|
116 |
+
isset($pd_options['set_checkout_language']) ? $pd_options['set_checkout_language'] : false);
|
117 |
+
?>
|
118 |
+
|
119 |
+
<?php
|
120 |
+
if (isset($pd_options['checkout_language'])) { $checkout_language = $pd_options['checkout_language']; } else { $checkout_language = ''; }
|
121 |
+
?>
|
122 |
+
<select name="checkout_language" id="checkout_language">
|
123 |
+
<option value="">None</option>
|
124 |
+
<?php
|
125 |
+
foreach ( $checkout_languages as $key => $language ) {
|
126 |
+
echo '<option value="'.$key.'"';
|
127 |
+
if ($checkout_language == $key) { echo ' selected="selected"'; }
|
128 |
+
echo '>'.$language.'</option>';
|
129 |
+
}?>
|
130 |
+
</select>
|
131 |
+
<br/>
|
132 |
+
|
133 |
+
|
134 |
+
<p class="submit">
|
135 |
+
<input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Changes', 'paypal-donations' ) ?>" />
|
136 |
+
</p>
|
137 |
+
</div>
|
views/paypal-button.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- Begin PayPal Donations by http://johansteen.se/ -->
|
2 |
+
<form action="<?php echo apply_filters( 'paypal_donations_url', 'https://www.paypal.com/cgi-bin/webscr'); ?>" method="post">
|
3 |
+
<div class="paypal-donations">
|
4 |
+
<input type="hidden" name="cmd" value="_donations" />
|
5 |
+
<input type="hidden" name="business" value="<?php echo $pd_options['paypal_account']; ?>" />
|
6 |
+
<?php
|
7 |
+
# Build the button
|
8 |
+
$paypal_btn = '';
|
9 |
+
|
10 |
+
// Optional Settings
|
11 |
+
if ($pd_options['page_style'])
|
12 |
+
$paypal_btn .= '<input type="hidden" name="page_style" value="' .$pd_options['page_style']. '" />';
|
13 |
+
if ($return_page)
|
14 |
+
$paypal_btn .= '<input type="hidden" name="return" value="' .$return_page. '" />'; // Return Page
|
15 |
+
if ($purpose)
|
16 |
+
$paypal_btn .= apply_filters('paypal_donations_purpose_html', '<input type="hidden" name="item_name" value="' .$purpose. '" />'); // Purpose
|
17 |
+
if ($reference)
|
18 |
+
$paypal_btn .= '<input type="hidden" name="item_number" value="' .$reference. '" />'; // LightWave Plugin
|
19 |
+
if ($amount)
|
20 |
+
$paypal_btn .= '<input type="hidden" name="amount" value="' . apply_filters( 'paypal_donations_amount', $amount ) . '" />';
|
21 |
+
|
22 |
+
// More Settings
|
23 |
+
if (isset($pd_options['currency_code']))
|
24 |
+
$paypal_btn .= '<input type="hidden" name="currency_code" value="' .$pd_options['currency_code']. '" />';
|
25 |
+
if (isset($pd_options['button_localized']))
|
26 |
+
{ $button_localized = $pd_options['button_localized']; } else { $button_localized = 'en_US'; }
|
27 |
+
if (isset($pd_options['set_checkout_language']) and $pd_options['set_checkout_language'] == true)
|
28 |
+
$paypal_btn .= '<input type="hidden" name="lc" value="' .$pd_options['checkout_language']. '" />';
|
29 |
+
|
30 |
+
// Settings not implemented yet
|
31 |
+
// $paypal_btn .= '<input type="hidden" name="amount" value="20" />';
|
32 |
+
|
33 |
+
// Get the button URL
|
34 |
+
if ( $pd_options['button'] != "custom" && !$button_url)
|
35 |
+
$button_url = str_replace('en_US', $button_localized, $donate_buttons[$pd_options['button']]);
|
36 |
+
$paypal_btn .= '<input type="image" src="' .$button_url. '" name="submit" alt="PayPal - The safer, easier way to pay online." />';
|
37 |
+
|
38 |
+
// PayPal stats tracking
|
39 |
+
if (!isset($pd_options['disable_stats']) or $pd_options['disable_stats'] != true)
|
40 |
+
$paypal_btn .= '<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />';
|
41 |
+
echo $paypal_btn;
|
42 |
+
?>
|
43 |
+
</div>
|
44 |
+
</form>
|
45 |
+
<!-- End PayPal Donations -->
|
views/widget-form.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
<label for="<?php echo $title_id; ?>"><?php _e('Title:', 'paypal-donations'); ?>
|
3 |
+
<input class="widefat" id="<?php echo $title_id; ?>" name="<?php echo $title_name; ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" />
|
4 |
+
</label>
|
5 |
+
</p>
|
6 |
+
|
7 |
+
<p>
|
8 |
+
<label for="<?php echo $text_id; ?>"><?php _e('Text:', 'paypal-donations'); ?>
|
9 |
+
<textarea class="widefat" id="<?php echo $text_id; ?>" name="<?php echo $text_name; ?>"><?php echo esc_attr($instance['text']); ?></textarea>
|
10 |
+
</label>
|
11 |
+
</p>
|
12 |
+
|
13 |
+
<p>
|
14 |
+
<label for="<?php echo $purpose_id; ?>"><?php _e('Purpose:', 'paypal-donations'); ?>
|
15 |
+
<input class="widefat" id="<?php echo $purpose_id; ?>" name="<?php echo $purpose_name; ?>" type="text" value="<?php echo esc_attr($instance['purpose']); ?>" />
|
16 |
+
</label>
|
17 |
+
</p>
|
18 |
+
|
19 |
+
<p>
|
20 |
+
<label for="<?php echo $reference_id; ?>"><?php _e('Reference:', 'paypal-donations'); ?>
|
21 |
+
<input class="widefat" id="<?php echo $reference_id; ?>" name="<?php echo $reference_name; ?>" type="text" value="<?php echo esc_attr($instance['reference']); ?>" />
|
22 |
+
</label>
|
23 |
+
</p>
|