PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.1.0
GiveWP – Donation Plugin and Fundraising Platform v2.1.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-general.php
give / includes / admin / settings Last commit date
class-settings-addon.php 8 years ago class-settings-advanced.php 8 years ago class-settings-cmb2-backward-compatibility.php 8 years ago class-settings-display.php 8 years ago class-settings-email.php 8 years ago class-settings-gateways.php 8 years ago class-settings-general.php 8 years ago class-settings-license.php 8 years ago
class-settings-general.php
519 lines
1 <?php
2 /**
3 * Give Settings Page/Tab
4 *
5 * @package Give
6 * @subpackage Classes/Give_Settings_General
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_General' ) ) :
17
18 /**
19 * Give_Settings_General.
20 *
21 * @sine 1.8
22 */
23 class Give_Settings_General extends Give_Settings_Page {
24
25 /**
26 * Constructor.
27 */
28 public function __construct() {
29 $this->id = 'general';
30 $this->label = __( 'General', 'give' );
31
32 $this->default_tab = 'general-settings';
33
34 if ( $this->id === give_get_current_setting_tab() ) {
35 add_action( 'give_save_settings_give_settings', array( $this, '__give_change_donation_stating_number' ), 10, 3 );
36 add_action( 'give_admin_field_give_sequential_donation_code_preview', array( $this, '__render_give_sequential_donation_code_preview' ), 10, 3 );
37 add_action( 'give_admin_field_give_unlock_all_settings', array( $this, '__render_give_unlock_all_settings' ), 10, 3 );
38 }
39
40 parent::__construct();
41 }
42
43 /**
44 * Get settings array.
45 *
46 * @since 1.8
47 * @return array
48 */
49 public function get_settings() {
50 $settings = array();
51 $current_section = give_get_current_setting_section();
52
53 switch ( $current_section ) {
54 case 'access-control':
55 $settings = array(
56 // Section 3: Access control.
57 array(
58 'id' => 'give_title_session_control_1',
59 'type' => 'title',
60 ),
61 array(
62 'id' => 'session_lifetime',
63 'name' => __( 'Session Lifetime', 'give' ),
64 'desc' => __( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ),
65 'type' => 'select',
66 'options' => array(
67 '86400' => __( '24 Hours', 'give' ),
68 '172800' => __( '48 Hours', 'give' ),
69 '259200' => __( '72 Hours', 'give' ),
70 '604800' => __( '1 Week', 'give' ),
71 ),
72 ),
73 array(
74 'id' => 'limit_display_donations',
75 'name' => __( 'Limit Donations Displayed', 'give' ),
76 'desc' => __( 'Adjusts the number of donations displayed to a non logged-in user when they attempt to access the Donation History page without an active session. For security reasons, it\'s best to leave this at 1-3 donations.', 'give' ),
77 'default' => '1',
78 'type' => 'number',
79 'css' => 'width:50px;',
80 'attributes' => array(
81 'min' => '1',
82 'max' => '10',
83 ),
84 ),
85 array(
86 'name' => __( 'Email Access', 'give' ),
87 'desc' => __( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ),
88 'id' => 'email_access',
89 'type' => 'radio_inline',
90 'default' => 'disabled',
91 'options' => array(
92 'enabled' => __( 'Enabled', 'give' ),
93 'disabled' => __( 'Disabled', 'give' ),
94 ),
95 ),
96 array(
97 'name' => __( 'Enable reCAPTCHA', 'give' ),
98 'desc' => __( 'Would you like to enable the reCAPTCHA feature?', 'give' ),
99 'id' => 'enable_recaptcha',
100 'type' => 'radio_inline',
101 'default' => 'disabled',
102 'options' => array(
103 'enabled' => __( 'Enabled', 'give' ),
104 'disabled' => __( 'Disabled', 'give' ),
105 ),
106 ),
107 array(
108 'id' => 'recaptcha_key',
109 'name' => __( 'reCAPTCHA Site Key', 'give' ),
110 /* translators: %s: https://www.google.com/recaptcha/ */
111 'desc' => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key and paste your reCAPTCHA site key here. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'http://docs.givewp.com/recaptcha' ) ),
112 'default' => '',
113 'type' => 'text',
114 ),
115 array(
116 'id' => 'recaptcha_secret',
117 'name' => __( 'reCAPTCHA Secret Key', 'give' ),
118 'desc' => __( 'Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give' ),
119 'default' => '',
120 'type' => 'text',
121 ),
122 array(
123 'name' => __( 'Access Control Docs Link', 'give' ),
124 'id' => 'access_control_docs_link',
125 'url' => esc_url( 'http://docs.givewp.com/settings-access-control' ),
126 'title' => __( 'Access Control', 'give' ),
127 'type' => 'give_docs_link',
128 ),
129 array(
130 'id' => 'give_title_session_control_1',
131 'type' => 'sectionend',
132 ),
133 );
134 break;
135
136 case 'currency-settings' :
137 $currency_position_before = __( 'Before - %s&#x200e;10', 'give' );
138 $currency_position_after = __( 'After - 10%s&#x200f;', 'give' );
139
140 $settings = array(
141 // Section 2: Currency
142 array(
143 'type' => 'title',
144 'id' => 'give_title_general_settings_2',
145 ),
146 array(
147 'name' => __( 'Currency Settings', 'give' ),
148 'desc' => '',
149 'type' => 'give_title',
150 'id' => 'give_title_general_settings_2',
151 ),
152 array(
153 'name' => __( 'Currency', 'give' ),
154 'desc' => __( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ),
155 'id' => 'currency',
156 'class' => 'give-select-chosen',
157 'type' => 'select',
158 'options' => give_get_currencies(),
159 'default' => 'USD',
160 ),
161 array(
162 'name' => __( 'Currency Position', 'give' ),
163 'desc' => __( 'The position of the currency symbol.', 'give' ),
164 'id' => 'currency_position',
165 'type' => 'select',
166 'options' => array(
167 /* translators: %s: currency symbol */
168 'before' => sprintf( $currency_position_before, give_currency_symbol( give_get_currency() ) ),
169 /* translators: %s: currency symbol */
170 'after' => sprintf( $currency_position_after, give_currency_symbol( give_get_currency() ) ),
171 ),
172 'default' => 'before',
173 'attributes' => array(
174 'data-before-template' => sprintf( $currency_position_before, '{currency_pos}' ),
175 'data-after-template' => sprintf( $currency_position_after, '{currency_pos}' ),
176 ),
177 ),
178 array(
179 'name' => __( 'Thousands Separator', 'give' ),
180 'desc' => __( 'The symbol (typically , or .) to separate thousands.', 'give' ),
181 'id' => 'thousands_separator',
182 'type' => 'text',
183 'default' => ',',
184 'css' => 'width:12em;',
185 ),
186 array(
187 'name' => __( 'Decimal Separator', 'give' ),
188 'desc' => __( 'The symbol (usually , or .) to separate decimal points.', 'give' ),
189 'id' => 'decimal_separator',
190 'type' => 'text',
191 'default' => '.',
192 'css' => 'width:12em;',
193 ),
194 array(
195 'name' => __( 'Number of Decimals', 'give' ),
196 'desc' => __( 'The number of decimal points displayed in amounts.', 'give' ),
197 'id' => 'number_decimals',
198 'type' => 'text',
199 'default' => 2,
200 'css' => 'width:12em;',
201 ),
202 array(
203 'name' => __( 'Currency Options Docs Link', 'give' ),
204 'id' => 'currency_settings_docs_link',
205 'url' => esc_url( 'http://docs.givewp.com/settings-currency' ),
206 'title' => __( 'Currency Settings', 'give' ),
207 'type' => 'give_docs_link',
208 ),
209 array(
210 'type' => 'sectionend',
211 'id' => 'give_title_general_settings_2',
212 ),
213 );
214
215 break;
216
217 case 'general-settings':
218 // Get default country code.
219 $country = give_get_country();
220
221 // get the list of the states of which default country is selected.
222 $states = give_get_states( $country );
223
224 // Get the country list that does not have any states init.
225 $no_states_country = give_no_states_country_list();
226
227 $settings = array(
228 // Section 1: General.
229 array(
230 'type' => 'title',
231 'id' => 'give_title_general_settings_1',
232 ),
233 array(
234 'name' => __( 'General Settings', 'give' ),
235 'desc' => '',
236 'type' => 'give_title',
237 'id' => 'give_title_general_settings_1',
238 ),
239 array(
240 'name' => __( 'Success Page', 'give' ),
241 /* translators: %s: [give_receipt] */
242 'desc' => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ),
243 'id' => 'success_page',
244 'class' => 'give-select give-select-chosen',
245 'type' => 'select',
246 'options' => give_cmb2_get_post_options( array(
247 'post_type' => 'page',
248 'numberposts' => 30,
249 ) ),
250 'attributes' => array(
251 'data-search-type' => 'pages'
252 )
253 ),
254 array(
255 'name' => __( 'Failed Donation Page', 'give' ),
256 'desc' => __( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ),
257 'class' => 'give-select give-select-chosen',
258 'id' => 'failure_page',
259 'type' => 'select',
260 'options' => give_cmb2_get_post_options( array(
261 'post_type' => 'page',
262 'numberposts' => 30,
263 ) ),
264 'attributes' => array(
265 'data-search-type' => 'pages'
266 )
267 ),
268 array(
269 'name' => __( 'Donation History Page', 'give' ),
270 /* translators: %s: [donation_history] */
271 'desc' => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ),
272 'id' => 'history_page',
273 'class' => 'give-select give-select-chosen',
274 'type' => 'select',
275 'options' => give_cmb2_get_post_options( array(
276 'post_type' => 'page',
277 'numberposts' => 30,
278 ) ),
279 'attributes' => array(
280 'data-search-type' => 'pages'
281 )
282 ),
283 array(
284 'name' => __( 'Base Country', 'give' ),
285 'desc' => __( 'The country your site operates from.', 'give' ),
286 'id' => 'base_country',
287 'type' => 'select',
288 'options' => give_get_country_list(),
289 ),
290 /**
291 * Add base state to give setting
292 *
293 * @since 1.8.14
294 */
295 array(
296 'wrapper_class' => ( array_key_exists( $country, $no_states_country ) ? 'give-hidden' : '' ),
297 'name' => __( 'Base State/Province', 'give' ),
298 'desc' => __( 'The state/province your site operates from.', 'give' ),
299 'id' => 'base_state',
300 'type' => ( empty( $states ) ? 'text' : 'select' ),
301 'options' => $states,
302 ),
303 array(
304 'name' => __( 'General Options Docs Link', 'give' ),
305 'id' => 'general_options_docs_link',
306 'url' => esc_url( 'http://docs.givewp.com/settings-general' ),
307 'title' => __( 'General Options', 'give' ),
308 'type' => 'give_docs_link',
309 ),
310 array(
311 'type' => 'sectionend',
312 'id' => 'give_title_general_settings_1',
313 ),
314 );
315 break;
316
317 case 'sequential-ordering':
318 $settings = array(
319
320 // Section 4: Sequential Ordering
321
322 array(
323 'id' => 'give_title_general_settings_4',
324 'type' => 'title'
325 ),
326 array(
327 'name' => __( 'Sequential Ordering', 'give' ),
328 'id' => "{$current_section}_status",
329 'desc' => __( 'Custom donation numbering that increases sequentially to prevent gaps between donation IDs. If disabled, then donation numbers are generated from WordPress post IDs, which will result in gaps between numbers.', 'give' ),
330 'type' => 'radio_inline',
331 'default' => 'disabled',
332 'options' => array(
333 'enabled' => __( 'Enabled', 'give' ),
334 'disabled' => __( 'Disabled', 'give' )
335 )
336 ),
337 array(
338 'name' => __( 'Next Donation Number', 'give' ),
339 'id' => "{$current_section}_number",
340 'desc' => sprintf(
341 __( 'The number used to generate the next donation ID. This value must be greater than or equal to %s to avoid conflicts with existing donation IDs.', 'give' ),
342 '<code>' . Give()->seq_donation_number->get_next_number() . '</code>'
343 ),
344 'type' => 'number',
345 ),
346 array(
347 'name' => __( 'Number Prefix', 'give' ),
348 'id' => "{$current_section}_number_prefix",
349 'desc' => sprintf(
350 __( 'The prefix appended to all sequential donation numbers. Spaces are replaced by %s.', 'give' ),
351 '<code>-</code>'
352 ),
353 'type' => 'text',
354 ),
355 array(
356 'name' => __( 'Number Suffix', 'give' ),
357 'id' => "{$current_section}_number_suffix",
358 'desc' => sprintf(
359 __( 'The suffix appended to all sequential donation numbers. Spaces are replaced by %s.', 'give' ),
360 '<code>-</code>'
361 ),
362 'type' => 'text',
363 ),
364 array(
365 'name' => __( 'Number Padding', 'give' ),
366 'id' => "{$current_section}_number_padding",
367 'desc' => sprintf(
368 __( 'The minimum number of digits in the sequential donation number. Enter %s to display %s as %s.', 'give' ),
369 '<code>4</code>',
370 '<code>1</code>',
371 '<code>0001</code>'
372 ),
373 'type' => 'number',
374 'default' => '0',
375 ),
376 array(
377 'name' => __( 'Donation ID Preview', 'give' ),
378 'id' => "{$current_section}_preview",
379 'type' => 'give_sequential_donation_code_preview',
380 'desc' => __( 'A preview of the next sequential donation ID. This preview cannot be edited directly as it is generated from the settings above.', 'give' ),
381 ),
382 array(
383 'name' => __( 'Sequential Ordering Docs Link', 'give' ),
384 'id' => "{$current_section}_doc link",
385 'url' => esc_url( 'http://docs.givewp.com/settings-sequential-ordering' ),
386 'title' => __( 'Sequential Ordering', 'give' ),
387 'type' => 'give_docs_link',
388 ),
389 array(
390 'id' => 'give_title_general_settings_4',
391 'type' => 'sectionend'
392 )
393 );
394 }
395
396 /**
397 * Filter the general settings.
398 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
399 */
400 $settings = apply_filters( 'give_settings_general', $settings );
401
402 /**
403 * Filter the settings.
404 *
405 * @since 1.8
406 *
407 * @param array $settings
408 */
409 $settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
410
411 // Output.
412 return $settings;
413 }
414
415 /**
416 * Get sections.
417 *
418 * @since 1.8
419 * @return array
420 */
421 public function get_sections() {
422 $sections = array(
423 'general-settings' => __( 'General', 'give' ),
424 'currency-settings' => __( 'Currency', 'give' ),
425 'access-control' => __( 'Access Control', 'give' ),
426 'sequential-ordering' => __( 'Sequential Ordering', 'give' ),
427 );
428
429 return apply_filters( 'give_get_sections_' . $this->id, $sections );
430 }
431
432
433 /**
434 * Set flag to reset sequestion donation number starting point when "Sequential Starting Number" value changes
435 *
436 * @since 2.1
437 * @access public
438 *
439 * @param $update_options
440 * @param $option_name
441 * @param $old_options
442 *
443 * @return bool
444 */
445 public function __give_change_donation_stating_number( $update_options, $option_name, $old_options ) {
446 if ( ! isset( $_POST['sequential-ordering_number'] ) ) {
447 return false;
448 }
449
450 if ( ( $next_number = Give()->seq_donation_number->get_next_number() ) > $update_options['sequential-ordering_number'] ) {
451 give_update_option( 'sequential-ordering_number', $next_number );
452
453 Give_Admin_Settings::add_error(
454 'give-invalid-sequential-starting-number',
455 sprintf(
456 __( 'Next Donation Number must be equal to or larger than %s to avoid conflicts with existing donation IDs.', 'give' ),
457 $next_number
458 )
459 );
460 } elseif ( $update_options['sequential-ordering_number'] !== $old_options['sequential-ordering_number'] ) {
461 update_option( '_give_reset_sequential_number', 1 );
462 }
463
464 return true;
465 }
466
467
468 /**
469 * Render give_sequential_donation_code_preview field type
470 *
471 * @since 2.1.0
472 * @access public
473 *
474 * @param $field
475 */
476 public function __render_give_sequential_donation_code_preview( $field ) {
477 ?>
478 <tr valign="top" <?php echo ! empty( $field['wrapper_class'] ) ? 'class="' . $field['wrapper_class'] . '"' : '' ?>>
479 <th scope="row" class="titledesc">
480 <label
481 for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo esc_html( $field['name'] ) ?></label>
482 </th>
483 <td class="give-forminp">
484 <input id="<?php echo esc_attr( $field['id'] ); ?>" class="give-input-field" type="text" disabled>
485 <?php echo Give_Admin_Settings::get_field_description( $field ); ?>
486 </td>
487 </tr>
488 <?php
489 }
490
491
492 /**
493 * Render give_unlock_all_settings field type
494 *
495 * @since 2.1.0
496 * @access public
497 *
498 * @param $field
499 */
500 public function __render_give_unlock_all_settings( $field ) {
501 ?>
502 <tr valign="top" <?php echo ! empty( $field['wrapper_class'] ) ? 'class="' . $field['wrapper_class'] . '"' : '' ?>>
503 <th scope="row" class="titledesc">
504 <label
505 for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo esc_html( $field['name'] ) ?></label>
506 </th>
507 <td class="give-forminp">
508 <?php echo Give_Admin_Settings::get_field_description( $field ); ?>
509 <a href="" id="<?php echo $field['id']; ?>" data-message="<?php echo $field['confirmation_msg'] ?>"><?php echo __( 'Unlock all settings', 'give' ); ?></a>
510 </td>
511 </tr>
512 <?php
513 }
514 }
515
516 endif;
517
518 return new Give_Settings_General();
519