PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.33.3
GiveWP – Donation Plugin and Fundraising Platform v2.33.3
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 6 years ago class-settings-advanced.php 2 years ago class-settings-display.php 4 years ago class-settings-email.php 3 years ago class-settings-gateways.php 2 years ago class-settings-general.php 3 years ago class-settings-license.php 4 years ago class-settings-recurring.php 3 years ago
class-settings-gateways.php
412 lines
1 <?php
2 /**
3 * Give Settings Page/Tab
4 *
5 * @package Give
6 * @since 1.8
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @subpackage Classes/Give_Settings_Gateways
10 */
11
12 use Give\PaymentGateways\PayPalCommerce\Repositories\MerchantDetails;
13 use Give\PaymentGateways\Stripe\Admin\AccountManagerSettingField;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly
17 }
18
19 if ( ! class_exists( 'Give_Settings_Gateways' ) ) :
20
21 /**
22 * Give_Settings_Gateways.
23 *
24 * @sine 1.8
25 */
26 class Give_Settings_Gateways extends Give_Settings_Page {
27
28 /**
29 * Constructor.
30 */
31 public function __construct() {
32 $this->id = 'gateways';
33 $this->label = esc_html__( 'Payment Gateways', 'give' );
34
35 $this->default_tab = 'gateways-settings';
36
37 parent::__construct();
38
39 // Do not use main form for this tab.
40 if ( give_get_current_setting_tab() === $this->id ) {
41 add_action('give_admin_field_gateway_notice', [$this, 'render_gateway_notice'], 10, 2);
42 add_action('give_admin_field_enabled_gateways', [$this, 'render_enabled_gateways'], 10, 2);
43 }
44 }
45
46 /**
47 * Get settings array.
48 *
49 * @since 1.8
50 * @return array
51 */
52 public function get_settings() {
53 $settings = [];
54 $current_section = give_get_current_setting_section();
55
56 switch ( $current_section ) {
57 case 'offline-donations':
58 $settings = [
59 // Section 3: Offline gateway.
60 [
61 'type' => 'title',
62 'id' => 'give_title_gateway_settings_3',
63 ],
64 [
65 'name' => __( 'Collect Billing Details', 'give' ),
66 'desc' => __( 'If enabled, required billing address fields are added to Offline Donation forms. These fields are not required to process the transaction, but you may have a need to collect the data. Billing address details are added to both the donation and donor record in GiveWP. ', 'give' ),
67 'id' => 'give_offline_donation_enable_billing_fields',
68 'type' => 'radio_inline',
69 'default' => 'disabled',
70 'options' => [
71 'enabled' => __( 'Enabled', 'give' ),
72 'disabled' => __( 'Disabled', 'give' ),
73 ],
74 ],
75 [
76 'name' => __( 'Offline Donation Instructions', 'give' ),
77 'desc' => __( 'The Offline Donation Instructions are a chance for you to educate the donor on how to best submit offline donations. These instructions appear directly on the form, and after submission of the form. Note: You may also customize the instructions on individual forms as needed.', 'give' ),
78 'id' => 'global_offline_donation_content',
79 'default' => give_get_default_offline_donation_content(),
80 'type' => 'wysiwyg',
81 'options' => [
82 'textarea_rows' => 6,
83 ],
84 ],
85 [
86 'name' => esc_html__( 'Offline Donations Settings Docs Link', 'give' ),
87 'id' => 'offline_gateway_settings_docs_link',
88 'url' => esc_url( 'http://docs.givewp.com/offlinegateway' ),
89 'title' => __( 'Offline Gateway Settings', 'give' ),
90 'type' => 'give_docs_link',
91 ],
92 [
93 'type' => 'sectionend',
94 'id' => 'give_title_gateway_settings_3',
95 ],
96 ];
97 break;
98
99 case 'gateways-settings':
100 $settings = [
101 // Section 1: Gateways.
102 [
103 'id' => 'give_title_gateway_settings_1',
104 'type' => 'title',
105 ],
106 [
107 'id' => 'gateway_notice',
108 'type' => 'gateway_notice',
109 ],
110 [
111 'name' => __('Test Mode', 'give'),
112 'desc' => __(
113 'If enabled, donations are processed through the sandbox/test accounts configured in each gateway\'s settings. This prevents having to use real money for tests. See the payment gateway documentation for instructions on configuring sandbox accounts.',
114 'give'
115 ),
116 'id' => 'test_mode',
117 'type' => 'radio_inline',
118 'default' => 'disabled',
119 'options' => [
120 'enabled' => __('Enabled', 'give'),
121 'disabled' => __('Disabled', 'give'),
122 ],
123 ],
124 [
125 'name' => __('Enabled Gateways', 'give'),
126 'desc' => __('Enable your payment gateway. Can be ordered by dragging.', 'give'),
127 'id' => 'gateways',
128 'type' => 'enabled_gateways',
129 ],
130
131 /**
132 * "Enabled Gateways" setting field contains gateways label setting but when you save gateway settings then label will not save
133 * because this is not registered setting API and code will not recognize them.
134 *
135 * 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.
136 */
137 [
138 'name' => __('Gateways Label', 'give'),
139 'desc' => '',
140 'id' => 'gateways_label',
141 'type' => 'gateways_label_hidden',
142 ],
143
144 /**
145 * "Enabled Gateways" setting field contains default gateway setting but when you save gateway settings then this setting will not save
146 * because this is not registered setting API and code will not recognize them.
147 *
148 * 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.
149 */
150 [
151 'name' => __('Default Gateway', 'give'),
152 'desc' => __('The gateway that will be selected by default.', 'give'),
153 'id' => 'default_gateway',
154 'type' => 'default_gateway_hidden',
155 ],
156
157 [
158 'name' => __('Gateways Docs Link', 'give'),
159 'id' => 'gateway_settings_docs_link',
160 'url' => esc_url('http://docs.givewp.com/settings-gateways'),
161 'title' => __('Gateway Settings', 'give'),
162 'type' => 'give_docs_link',
163 ],
164 [
165 'id' => 'give_title_gateway_settings_1',
166 'type' => 'sectionend',
167 ],
168 ];
169 break;
170 }
171
172 /**
173 * Filter the payment gateways settings.
174 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
175 */
176 $settings = apply_filters('give_settings_gateways', $settings);
177
178 /**
179 * Filter the settings.
180 *
181 * @since 1.8
182 *
183 * @param array $settings
184 */
185 $settings = apply_filters('give_get_settings_' . $this->id, $settings);
186
187 // Output.
188 return $settings;
189 }
190
191 /**
192 * Get sections.
193 *
194 * @since 2.9.0 move offline-donations to end of gateway list
195 * @since 1.8
196 *
197 * @return array
198 */
199 public function get_sections()
200 {
201 $sections = apply_filters(
202 'give_get_sections_' . $this->id,
203 [
204 'gateways-settings' => __('Gateways', 'give'),
205 ]
206 );
207
208 $sections['offline-donations'] = __('Offline Donations', 'give');
209
210 return $sections;
211 }
212
213 /**
214 * @since 2.13.0
215 * @return bool
216 */
217 private function hasPremiumPaymentGateway()
218 {
219 $gateways = give_get_payment_gateways();
220
221 return (bool)apply_filters('give_gateway_upsell_notice_conditions', count($gateways) > 8);
222 }
223
224 /**
225 * @since 2.13.0
226 *
227 * @return bool
228 */
229 private function canAcceptCreditCard()
230 {
231 return Give\Helpers\Gateways\Stripe::isAccountConfigured() ||
232 give(MerchantDetails::class)->accountIsConnected();
233 }
234
235
236 /**
237 * Render Gateway Notice
238 *
239 * @since 2.3.0
240 * @access public
241 *
242 * @param $field
243 * @param $settings
244 */
245 public function render_gateway_notice($field, $settings)
246 {
247 if ( ! $this->hasPremiumPaymentGateway() && ! $this->canAcceptCreditCard()) {
248 ?>
249 <div class="give-gateways-notice">
250 <div class="give-gateways-cc-icon">
251 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="35"
252 height="29" viewBox="0 0 35 29">
253 <defs>
254 <path id="credit-card-a"
255 d="M32.0772569,3.88888889 L2.92274306,3.88888889 C1.30642361,3.88888889 0,5.1953125 0,6.80555556 L0,28.1944444 C0,29.8046875 1.30642361,31.1111111 2.92274306,31.1111111 L32.0772569,31.1111111 C33.6935764,31.1111111 35,29.8046875 35,28.1944444 L35,6.80555556 C35,5.1953125 33.6935764,3.88888889 32.0772569,3.88888889 Z M3.28732639,6.80555556 L31.7126736,6.80555556 C31.9131944,6.80555556 32.0772569,6.96961806 32.0772569,7.17013889 L32.0772569,9.72222222 L2.92274306,9.72222222 L2.92274306,7.17013889 C2.92274306,6.96961806 3.08680556,6.80555556 3.28732639,6.80555556 Z M31.7126736,28.1944444 L3.28732639,28.1944444 C3.08680556,28.1944444 2.92274306,28.0303819 2.92274306,27.8298611 L2.92274306,17.5 L32.0772569,17.5 L32.0772569,27.8298611 C32.0772569,28.0303819 31.9131944,28.1944444 31.7126736,28.1944444 Z M11.6666667,22.1180556 L11.6666667,24.5486111 C11.6666667,24.9496528 11.3385417,25.2777778 10.9375,25.2777778 L6.5625,25.2777778 C6.16145833,25.2777778 5.83333333,24.9496528 5.83333333,24.5486111 L5.83333333,22.1180556 C5.83333333,21.7170139 6.16145833,21.3888889 6.5625,21.3888889 L10.9375,21.3888889 C11.3385417,21.3888889 11.6666667,21.7170139 11.6666667,22.1180556 Z M23.3333333,22.1180556 L23.3333333,24.5486111 C23.3333333,24.9496528 23.0052083,25.2777778 22.6041667,25.2777778 L14.3402778,25.2777778 C13.9392361,25.2777778 13.6111111,24.9496528 13.6111111,24.5486111 L13.6111111,22.1180556 C13.6111111,21.7170139 13.9392361,21.3888889 14.3402778,21.3888889 L22.6041667,21.3888889 C23.0052083,21.3888889 23.3333333,21.7170139 23.3333333,22.1180556 Z" />
256 </defs>
257 <g fill="none" fill-rule="evenodd" opacity=".341" transform="translate(0 -3)">
258 <mask id="credit-card-b" fill="#fff">
259 <use xlink:href="#credit-card-a" />
260 </mask>
261 <g fill="#242A42" mask="url(#credit-card-b)">
262 <rect width="35" height="35" />
263 </g>
264 </g>
265 </svg>
266 </div>
267
268 <p class="give-gateways-notice-title">
269 <strong>
270 <?php esc_html_e(
271 'Want to accept credit card donations directly on your website?',
272 'give'
273 ); ?>
274 </strong>
275 </p>
276
277 <p class="give-gateways-notice-message">
278 <?php
279 printf(
280 __(
281 'Activate the free Stripe payment gateway %1$s, <a href="%2$s" target="_blank">PayPal Donations</a>, or a premium gateway like <a href="%3$s" target="_blank">Authorize.net</a>, or <a href="%4$s" target="_blank">Stripe Premium</a> for no added fees and priority support.',
282 'give'
283 ),
284 Give()->tooltips->render_help(
285 __(
286 'The free version of Stripe includes an additional 2% processing fee in addition to Stripe\'s normal fees for one-time donations. This ensures we can fully support the plugin for the future. Upgrade to the premium Stripe add-on for no added fees.',
287 'give'
288 )
289 ),
290 admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=paypal'),
291 'https://givewp.com/addons/authorize-net-gateway/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner',
292 'https://givewp.com/addons/stripe-gateway/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner'
293 );
294 ?>
295 </p>
296
297 <div class="give-gateways-notice-button">
298 <?php echo give(AccountManagerSettingField::class)->getStripeConnectButtonMarkup(); ?>
299 <a href="https://givewp.com/addons/category/payment-gateways/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner"
300 target="_blank" class="give-view-gateways-btn button">
301 <?php esc_html_e('View Premium Gateways', 'give'); ?>
302 </a>
303 </div>
304 </div>
305 <?php
306 }
307 }
308
309 /**
310 * Render enabled gateways
311 *
312 * @since 2.0.5
313 * @access public
314 *
315 * @param $field
316 * @param $settings
317 */
318 public function render_enabled_gateways( $field, $settings ) {
319 $id = $field['id'];
320 $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
321 $gateways_label = give_get_option( 'gateways_label', [] );
322 $default_gateway = give_get_option( 'default_gateway', current( array_keys( $gateways ) ) );
323
324 ob_start();
325
326 echo '<div class="gateway-enabled-wrap">';
327
328 echo '<div class="gateway-enabled-settings-title">';
329 printf(
330 '
331 <span></span>
332 <span>%1$s</span>
333 <span>%2$s</span>
334 <span>%3$s</span>
335 <span>%4$s</span>
336 ',
337 __( 'Gateway', 'give' ),
338 __( 'Label', 'give' ),
339 __( 'Default', 'give' ),
340 __( 'Enabled', 'give' )
341 );
342 echo '</div>';
343
344 echo '<ul class="give-checklist-fields give-payment-gatways-list">';
345 foreach ( $gateways as $key => $option ) :
346 $enabled = null;
347 if (is_array($settings) && array_key_exists($key, $settings)) {
348 $enabled = '1';
349 }
350
351 echo '<li>';
352 printf('<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>');
353 printf(
354 '<span class="admin-label">%1$s %2$s</span>',
355 esc_html($option['admin_label']),
356 !empty($option['admin_tooltip']) ? Give()->tooltips->render_help(
357 esc_attr($option['admin_tooltip'])
358 ) : ''
359 );
360
361 $label = '';
362 if (!empty($gateways_label[$key])) {
363 $label = $gateways_label[$key];
364 }
365
366 printf(
367 '<input class="checkout-label" type="text" id="%1$s[%2$s]" name="%1$s[%2$s]" value="%3$s" placeholder="%4$s"/>',
368 'gateways_label',
369 esc_attr($key),
370 esc_html($label),
371 esc_html($option['checkout_label'])
372 );
373
374 printf(
375 '<input class="gateways-radio" type="radio" name="%1$s" value="%2$s" %3$s %4$s>',
376 'default_gateway',
377 $key,
378 checked($key, $default_gateway, false),
379 disabled(null, $enabled, false)
380 );
381
382 printf(
383 '<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"/>',
384 esc_attr($id),
385 esc_attr($key),
386 checked('1', $enabled, false),
387 esc_html($option['admin_label'])
388 );
389 echo '</li>';
390 endforeach;
391 echo '</ul>';
392
393 echo '</div>'; // end gateway-enabled-wrap.
394
395 if (defined('GIVE_VERSION') && version_compare(GIVE_VERSION, '3.0.0', '<')) {
396 echo '<div style="padding-top: 1rem;"><p><sup>*</sup>(v2) GiveWP 3.0 is coming! In preparation for that, gateways that only work on forms created with GiveWP version 2.x.x are distinguished with a (v2) label.</p></div>';
397 } else {
398 echo '<div style="padding-top: 1rem;"><p><sup>*</sup>(v2) Gateways that only work on forms created with GiveWP version 2.x.x are distinguished with a (v2) label.</p></div>';
399 }
400
401 printf(
402 '<tr><th>%1$s</th><td>%2$s</td></tr>',
403 $field['title'],
404 ob_get_clean()
405 );
406 }
407 }
408
409 endif;
410
411 return new Give_Settings_Gateways();
412