PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.2.4
GiveWP – Donation Plugin and Fundraising Platform v2.2.4
4.16.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 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 7 years ago class-settings-general.php 7 years ago class-settings-license.php 8 years ago
class-settings-gateways.php
361 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 'id' => 'paypal_invoice_prefix',
107 'name' => esc_html__( 'Invoice ID Prefix', 'give' ),
108 'desc' => esc_html__( 'Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unique as PayPal will not allow orders with the same invoice number.', 'give' ),
109 'type' => 'text',
110 'default' => 'GIVE-',
111 ),
112 array(
113 'name' => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ),
114 'id' => 'paypal_standard_gateway_settings_docs_link',
115 'url' => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ),
116 'title' => __( 'PayPal Standard Gateway Settings', 'give' ),
117 'type' => 'give_docs_link',
118 ),
119 array(
120 'type' => 'sectionend',
121 'id' => 'give_title_gateway_settings_2',
122 )
123 );
124 break;
125
126 case 'offline-donations' :
127 $settings = array(
128 // Section 3: Offline gateway.
129 array(
130 'type' => 'title',
131 'id' => 'give_title_gateway_settings_3',
132 ),
133 array(
134 'name' => __( 'Collect Billing Details', 'give' ),
135 'desc' => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ),
136 'id' => 'give_offline_donation_enable_billing_fields',
137 'type' => 'radio_inline',
138 'default' => 'disabled',
139 'options' => array(
140 'enabled' => __( 'Enabled', 'give' ),
141 'disabled' => __( 'Disabled', 'give' )
142 )
143 ),
144 array(
145 'name' => __( 'Offline Donation Instructions', 'give' ),
146 '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' ),
147 'id' => 'global_offline_donation_content',
148 'default' => give_get_default_offline_donation_content(),
149 'type' => 'wysiwyg',
150 'options' => array(
151 'textarea_rows' => 6,
152 )
153 ),
154 array(
155 'name' => esc_html__( 'Offline Donations Settings Docs Link', 'give' ),
156 'id' => 'offline_gateway_settings_docs_link',
157 'url' => esc_url( 'http://docs.givewp.com/offlinegateway' ),
158 'title' => __( 'Offline Gateway Settings', 'give' ),
159 'type' => 'give_docs_link',
160 ),
161 array(
162 'type' => 'sectionend',
163 'id' => 'give_title_gateway_settings_3',
164 )
165 );
166 break;
167
168 case 'gateways-settings':
169 $settings = array(
170 // Section 1: Gateways.
171 array(
172 'id' => 'give_title_gateway_settings_1',
173 'type' => 'title'
174 ),
175 array(
176 'name' => __( 'Test Mode', 'give' ),
177 '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' ),
178 'id' => 'test_mode',
179 'type' => 'radio_inline',
180 'default' => 'disabled',
181 'options' => array(
182 'enabled' => __( 'Enabled', 'give' ),
183 'disabled' => __( 'Disabled', 'give' ),
184 )
185 ),
186 array(
187 'name' => __( 'Enabled Gateways', 'give' ),
188 'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ),
189 'id' => 'gateways',
190 'type' => 'enabled_gateways'
191 ),
192
193 /**
194 * "Enabled Gateways" setting field contains gateways label setting but when you save gateway settings then label will not save
195 * because this is not registered setting API and code will not recognize them.
196 *
197 * 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.
198 */
199 array(
200 'name' => __( 'Gateways Label', 'give' ),
201 'desc' => '',
202 'id' => 'gateways_label',
203 'type' => 'gateways_label_hidden'
204 ),
205
206 /**
207 * "Enabled Gateways" setting field contains default gateway setting but when you save gateway settings then this setting will not save
208 * because this is not registered setting API and code will not recognize them.
209 *
210 * 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.
211 */
212 array(
213 'name' => __( 'Default Gateway', 'give' ),
214 'desc' => __( 'The gateway that will be selected by default.', 'give' ),
215 'id' => 'default_gateway',
216 'type' => 'default_gateway_hidden'
217 ),
218
219 array(
220 'name' => __( 'Gateways Docs Link', 'give' ),
221 'id' => 'gateway_settings_docs_link',
222 'url' => esc_url( 'http://docs.givewp.com/settings-gateways' ),
223 'title' => __( 'Gateway Settings', 'give' ),
224 'type' => 'give_docs_link',
225 ),
226 array(
227 'id' => 'give_title_gateway_settings_1',
228 'type' => 'sectionend'
229 ),
230 );
231 break;
232 }
233
234 /**
235 * Filter the payment gateways settings.
236 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
237 */
238 $settings = apply_filters( 'give_settings_gateways', $settings );
239
240 /**
241 * Filter the settings.
242 *
243 * @since 1.8
244 *
245 * @param array $settings
246 */
247 $settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
248
249 // Output.
250 return $settings;
251 }
252
253 /**
254 * Get sections.
255 *
256 * @since 1.8
257 * @return array
258 */
259 public function get_sections() {
260 $sections = array(
261 'gateways-settings' => __( 'Gateways', 'give' ),
262 'paypal-standard' => __( 'PayPal Standard', 'give' ),
263 'offline-donations' => __( 'Offline Donations', 'give' )
264 );
265
266 return apply_filters( 'give_get_sections_' . $this->id, $sections );
267 }
268
269
270 /**
271 * Render enabled gateways
272 *
273 * @since 2.0.5
274 * @access public
275 *
276 * @param $field
277 * @param $settings
278 */
279 public function render_enabled_gateways( $field, $settings ) {
280 $id = $field['id'];
281 $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
282 $gateways_label = give_get_option( 'gateways_label', array() );
283 $default_gateway = give_get_option( 'default_gateway', current( array_keys( $gateways ) ) );
284
285 ob_start();
286
287 echo '<div class="gateway-enabled-wrap">';
288
289 echo '<div class="gateway-enabled-settings-title">';
290 printf(
291 '
292 <span></span>
293 <span>%1$s</span>
294 <span>%2$s</span>
295 <span>%3$s</span>
296 <span>%4$s</span>
297 ',
298 __( 'Gateway', 'give' ),
299 __( 'Label', 'give' ),
300 __( 'Default', 'give' ),
301 __( 'Enabled', 'give' )
302 );
303 echo '</div>';
304
305 echo '<ul class="give-checklist-fields give-payment-gatways-list">';
306 foreach ( $gateways as $key => $option ) :
307 $enabled = null;
308 if ( is_array( $settings ) && array_key_exists( $key, $settings ) ) {
309 $enabled = '1';
310 }
311
312 echo '<li>';
313 printf( '<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>' );
314 printf( '<span class="admin-label">%s</span>', esc_html( $option['admin_label'] ) );
315
316 $label = '';
317 if ( ! empty( $gateways_label[ $key ] ) ) {
318 $label = $gateways_label[ $key ];
319 }
320
321 printf(
322 '<input class="checkout-label" type="text" id="%1$s[%2$s]" name="%1$s[%2$s]" value="%3$s" placeholder="%4$s"/>',
323 'gateways_label',
324 esc_attr( $key ),
325 esc_html( $label ),
326 esc_html( $option['checkout_label'] )
327 );
328
329 printf(
330 '<input class="gateways-radio" type="radio" name="%1$s" value="%2$s" %3$s %4$s>',
331 'default_gateway',
332 $key,
333 checked( $key, $default_gateway, false ),
334 disabled( NULL, $enabled, false )
335 );
336
337 printf(
338 '<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"/>',
339 esc_attr( $id ),
340 esc_attr( $key ),
341 checked( '1', $enabled, false ),
342 esc_html( $option['admin_label'] )
343 );
344 echo '</li>';
345 endforeach;
346 echo '</ul>';
347
348 echo '</div>'; // end gateway-enabled-wrap.
349
350 printf(
351 '<tr><th>%1$s</th><td>%2$s</td></tr>',
352 $field['title'],
353 ob_get_clean()
354 );
355 }
356 }
357
358 endif;
359
360 return new Give_Settings_Gateways();
361