PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.2.0
GiveWP – Donation Plugin and Fundraising Platform v2.2.0
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / settings / class-settings-gateways.php
give / includes / admin / settings Last commit date
class-settings-addon.php 8 years ago class-settings-advanced.php 7 years ago class-settings-cmb2-backward-compatibility.php 8 years ago class-settings-display.php 7 years ago class-settings-email.php 7 years ago class-settings-gateways.php 8 years ago class-settings-general.php 7 years ago class-settings-license.php 8 years ago
class-settings-gateways.php
354 lines
1 <?php
2 /**
3 * Give Settings Page/Tab
4 *
5 * @package Give
6 * @subpackage Classes/Give_Settings_Gateways
7 * @copyright Copyright (c) 2016, WordImpress
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.8
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly
14 }
15
16 if ( ! class_exists( 'Give_Settings_Gateways' ) ) :
17
18 /**
19 * Give_Settings_Gateways.
20 *
21 * @sine 1.8
22 */
23 class Give_Settings_Gateways extends Give_Settings_Page {
24
25 /**
26 * Constructor.
27 */
28 public function __construct() {
29 $this->id = 'gateways';
30 $this->label = esc_html__( 'Payment Gateways', 'give' );
31
32 $this->default_tab = 'gateways-settings';
33
34 parent::__construct();
35
36 // Do not use main form for this tab.
37 if ( give_get_current_setting_tab() === $this->id ) {
38 add_action( 'give_admin_field_enabled_gateways', array( $this, 'render_enabled_gateways' ), 10, 2 );
39 }
40 }
41
42 /**
43 * Get settings array.
44 *
45 * @since 1.8
46 * @return array
47 */
48 public function get_settings() {
49 $settings = array();
50 $current_section = give_get_current_setting_section();
51
52 switch ( $current_section ) {
53 case 'paypal-standard':
54 $settings = array(
55 // Section 2: PayPal Standard.
56 array(
57 'type' => 'title',
58 'id' => 'give_title_gateway_settings_2',
59 ),
60 array(
61 'name' => __( 'PayPal Email', 'give' ),
62 'desc' => __( 'Enter your PayPal account\'s email.', 'give' ),
63 'id' => 'paypal_email',
64 'type' => 'email',
65 ),
66 array(
67 'name' => __( 'PayPal Page Style', 'give' ),
68 'desc' => __( 'Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give' ),
69 'id' => 'paypal_page_style',
70 'type' => 'text',
71 ),
72 array(
73 'name' => __( 'PayPal Transaction Type', 'give' ),
74 'desc' => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ),
75 'id' => 'paypal_button_type',
76 'type' => 'radio_inline',
77 'options' => array(
78 'donation' => __( 'Donation', 'give' ),
79 'standard' => __( 'Standard Transaction', 'give' )
80 ),
81 'default' => 'donation',
82 ),
83 array(
84 'name' => __( 'Billing Details', 'give' ),
85 'desc' => __( 'This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give' ),
86 'id' => 'paypal_standard_billing_details',
87 'type' => 'radio_inline',
88 'default' => 'disabled',
89 'options' => array(
90 'enabled' => __( 'Enabled', 'give' ),
91 'disabled' => __( 'Disabled', 'give' ),
92 )
93 ),
94 array(
95 'name' => __( 'PayPal IPN Verification', 'give' ),
96 'desc' => __( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ),
97 'id' => 'paypal_verification',
98 'type' => 'radio_inline',
99 'default' => 'enabled',
100 'options' => array(
101 'enabled' => __( 'Enabled', 'give' ),
102 'disabled' => __( 'Disabled', 'give' ),
103 )
104 ),
105 array(
106 'name' => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ),
107 'id' => 'paypal_standard_gateway_settings_docs_link',
108 'url' => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ),
109 'title' => __( 'PayPal Standard Gateway Settings', 'give' ),
110 'type' => 'give_docs_link',
111 ),
112 array(
113 'type' => 'sectionend',
114 'id' => 'give_title_gateway_settings_2',
115 )
116 );
117 break;
118
119 case 'offline-donations' :
120 $settings = array(
121 // Section 3: Offline gateway.
122 array(
123 'type' => 'title',
124 'id' => 'give_title_gateway_settings_3',
125 ),
126 array(
127 'name' => __( 'Collect Billing Details', 'give' ),
128 'desc' => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ),
129 'id' => 'give_offline_donation_enable_billing_fields',
130 'type' => 'radio_inline',
131 'default' => 'disabled',
132 'options' => array(
133 'enabled' => __( 'Enabled', 'give' ),
134 'disabled' => __( 'Disabled', 'give' )
135 )
136 ),
137 array(
138 'name' => __( 'Offline Donation Instructions', 'give' ),
139 'desc' => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ),
140 'id' => 'global_offline_donation_content',
141 'default' => give_get_default_offline_donation_content(),
142 'type' => 'wysiwyg',
143 'options' => array(
144 'textarea_rows' => 6,
145 )
146 ),
147 array(
148 'name' => esc_html__( 'Offline Donations Settings Docs Link', 'give' ),
149 'id' => 'offline_gateway_settings_docs_link',
150 'url' => esc_url( 'http://docs.givewp.com/offlinegateway' ),
151 'title' => __( 'Offline Gateway Settings', 'give' ),
152 'type' => 'give_docs_link',
153 ),
154 array(
155 'type' => 'sectionend',
156 'id' => 'give_title_gateway_settings_3',
157 )
158 );
159 break;
160
161 case 'gateways-settings':
162 $settings = array(
163 // Section 1: Gateways.
164 array(
165 'id' => 'give_title_gateway_settings_1',
166 'type' => 'title'
167 ),
168 array(
169 'name' => __( 'Test Mode', 'give' ),
170 'desc' => __( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ),
171 'id' => 'test_mode',
172 'type' => 'radio_inline',
173 'default' => 'disabled',
174 'options' => array(
175 'enabled' => __( 'Enabled', 'give' ),
176 'disabled' => __( 'Disabled', 'give' ),
177 )
178 ),
179 array(
180 'name' => __( 'Enabled Gateways', 'give' ),
181 'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ),
182 'id' => 'gateways',
183 'type' => 'enabled_gateways'
184 ),
185
186 /**
187 * "Enabled Gateways" setting field contains gateways label setting but when you save gateway settings then label will not save
188 * because this is not registered setting API and code will not recognize them.
189 *
190 * This setting will not render on admin setting screen but help internal code to recognize "gateways_label" setting and add them to give setting when save.
191 */
192 array(
193 'name' => __( 'Gateways Label', 'give' ),
194 'desc' => '',
195 'id' => 'gateways_label',
196 'type' => 'gateways_label_hidden'
197 ),
198
199 /**
200 * "Enabled Gateways" setting field contains default gateway setting but when you save gateway settings then this setting will not save
201 * because this is not registered setting API and code will not recognize them.
202 *
203 * This setting will not render on admin setting screen but help internal code to recognize "default_gateway" setting and add them to give setting when save.
204 */
205 array(
206 'name' => __( 'Default Gateway', 'give' ),
207 'desc' => __( 'The gateway that will be selected by default.', 'give' ),
208 'id' => 'default_gateway',
209 'type' => 'default_gateway_hidden'
210 ),
211
212 array(
213 'name' => __( 'Gateways Docs Link', 'give' ),
214 'id' => 'gateway_settings_docs_link',
215 'url' => esc_url( 'http://docs.givewp.com/settings-gateways' ),
216 'title' => __( 'Gateway Settings', 'give' ),
217 'type' => 'give_docs_link',
218 ),
219 array(
220 'id' => 'give_title_gateway_settings_1',
221 'type' => 'sectionend'
222 ),
223 );
224 break;
225 }
226
227 /**
228 * Filter the payment gateways settings.
229 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
230 */
231 $settings = apply_filters( 'give_settings_gateways', $settings );
232
233 /**
234 * Filter the settings.
235 *
236 * @since 1.8
237 *
238 * @param array $settings
239 */
240 $settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
241
242 // Output.
243 return $settings;
244 }
245
246 /**
247 * Get sections.
248 *
249 * @since 1.8
250 * @return array
251 */
252 public function get_sections() {
253 $sections = array(
254 'gateways-settings' => __( 'Gateways', 'give' ),
255 'paypal-standard' => __( 'PayPal Standard', 'give' ),
256 'offline-donations' => __( 'Offline Donations', 'give' )
257 );
258
259 return apply_filters( 'give_get_sections_' . $this->id, $sections );
260 }
261
262
263 /**
264 * Render enabled gateways
265 *
266 * @since 2.0.5
267 * @access public
268 *
269 * @param $field
270 * @param $settings
271 */
272 public function render_enabled_gateways( $field, $settings ) {
273 $id = $field['id'];
274 $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
275 $gateways_label = give_get_option( 'gateways_label', array() );
276 $default_gateway = give_get_option( 'default_gateway', current( array_keys( $gateways ) ) );
277
278 ob_start();
279
280 echo '<div class="gateway-enabled-wrap">';
281
282 echo '<div class="gateway-enabled-settings-title">';
283 printf(
284 '
285 <span></span>
286 <span>%1$s</span>
287 <span>%2$s</span>
288 <span>%3$s</span>
289 <span>%4$s</span>
290 ',
291 __( 'Gateway', 'give' ),
292 __( 'Label', 'give' ),
293 __( 'Default', 'give' ),
294 __( 'Enabled', 'give' )
295 );
296 echo '</div>';
297
298 echo '<ul class="give-checklist-fields give-payment-gatways-list">';
299 foreach ( $gateways as $key => $option ) :
300 $enabled = null;
301 if ( is_array( $settings ) && array_key_exists( $key, $settings ) ) {
302 $enabled = '1';
303 }
304
305 echo '<li>';
306 printf( '<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>' );
307 printf( '<span class="admin-label">%s</span>', esc_html( $option['admin_label'] ) );
308
309 $label = '';
310 if ( ! empty( $gateways_label[ $key ] ) ) {
311 $label = $gateways_label[ $key ];
312 }
313
314 printf(
315 '<input class="checkout-label" type="text" id="%1$s[%2$s]" name="%1$s[%2$s]" value="%3$s" placeholder="%4$s"/>',
316 'gateways_label',
317 esc_attr( $key ),
318 esc_html( $label ),
319 esc_html( $option['checkout_label'] )
320 );
321
322 printf(
323 '<input class="gateways-radio" type="radio" name="%1$s" value="%2$s" %3$s %4$s>',
324 'default_gateway',
325 $key,
326 checked( $key, $default_gateway, false ),
327 disabled( NULL, $enabled, false )
328 );
329
330 printf(
331 '<input class="gateways-checkbox" name="%1$s[%2$s]" id="%1$s[%2$s]" type="checkbox" value="1" %3$s data-payment-gateway="%4$s"/>',
332 esc_attr( $id ),
333 esc_attr( $key ),
334 checked( '1', $enabled, false ),
335 esc_html( $option['admin_label'] )
336 );
337 echo '</li>';
338 endforeach;
339 echo '</ul>';
340
341 echo '</div>'; // end gateway-enabled-wrap.
342
343 printf(
344 '<tr><th>%1$s</th><td>%2$s</td></tr>',
345 $field['title'],
346 ob_get_clean()
347 );
348 }
349 }
350
351 endif;
352
353 return new Give_Settings_Gateways();
354