PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / trunk
GiveWP – Donation Plugin and Fundraising Platform vtrunk
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-advanced.php
give / includes / admin / settings Last commit date
class-settings-addon.php 6 years ago class-settings-advanced.php 5 months ago class-settings-display.php 2 years ago class-settings-email.php 11 months ago class-settings-gateways.php 1 year ago class-settings-general.php 1 year ago class-settings-license.php 1 month ago class-settings-recurring.php 1 year ago
class-settings-advanced.php
496 lines
1 <?php
2 /**
3 * Give Settings Page/Tab
4 *
5 * @package Give
6 * @subpackage Classes/Give_Settings_Advanced
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.8
10 */
11
12 use Give\FeatureFlags\OptionBasedFormEditor\OptionBasedFormEditor;
13 use Give\Onboarding\Setup\Page as SetupPage;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly
17 }
18
19 if ( ! class_exists( 'Give_Settings_Advanced' ) ) :
20
21 /**
22 * Give_Settings_Advanced.
23 *
24 * @sine 1.8
25 */
26 class Give_Settings_Advanced extends Give_Settings_Page
27 {
28
29 /**
30 * Constructor.
31 */
32 public function __construct()
33 {
34 $this->id = 'advanced';
35 $this->label = __('Advanced', 'give');
36
37 $this->default_tab = 'advanced-options';
38
39 if ($this->id === give_get_current_setting_tab()) {
40 add_action(
41 'give_admin_field_remove_cache_button',
42 [
43 $this,
44 'render_remove_cache_button',
45 ],
46 10,
47 1
48 );
49 add_action('give_save_settings_give_settings', [$this, 'validate_settngs']);
50 add_filter( "give_admin_settings_sanitize_option_donor_default_user_role", [$this, 'sanitize_option_donor_default_user_role']);
51 add_action('give_admin_field_give_option_based_form_editor_notice',
52 [$this, '_render_give_based_form_editor_notice'], 10, 2);
53 }
54
55 parent::__construct();
56 }
57
58 /**
59 * Get settings array.
60 *
61 * @since 4.14.0 update donor default user role to use give_get_donor_safe_user_roles
62 * @since 4.1.0 Added Donation Forms section
63 * @since 1.8
64 * @return array
65 */
66 public function get_settings()
67 {
68 $settings = [];
69
70 $current_section = give_get_current_setting_section();
71 $setupPage = esc_url(admin_url('edit.php?post_type=give_forms&page=give-setup'));
72
73 switch ($current_section) {
74 case 'advanced-options':
75 $settings = [
76 [
77 'id' => 'give_title_data_control_2',
78 'type' => 'title',
79 ],
80 [
81 'name' => __('Option-Based Form Editor', 'give'),
82 'desc' => __('If enabled, you\'ll gain access to the legacy settings and can create forms using the Option-Based Editor. Disabling this option will not affect existing forms created with the Option-Based Editor.',
83 'give'),
84 'id' => 'option_based_form_editor',
85 'type' => 'radio_inline',
86 'default' => (OptionBasedFormEditor::existOptionBasedFormsOnDb()) ? 'enabled' : 'disabled',
87 'options' => [
88 'enabled' => __('Enabled', 'give'),
89 'disabled' => __('Disabled', 'give'),
90 ],
91 ],
92 [
93 'id' => 'option_based_form_editor_notice',
94 'type' => 'give_option_based_form_editor_notice',
95 ],
96 [
97 'name' => __('Default GiveWP Styles', 'give'),
98 'desc' => __('This controls GiveWP\'s default styles for legacy donation forms and other front end elements. Disabling this option means that you\'ll need to supply your own styles.',
99 'give'),
100 'id' => 'css',
101 'type' => 'radio_inline',
102 'default' => 'enabled',
103 'options' => [
104 'enabled' => __('Enabled', 'give'),
105 'disabled' => __('Disabled', 'give'),
106 ],
107 ],
108 [
109 'name' => __('Remove Data on Uninstall', 'give'),
110 'desc' => __('When the plugin is deleted, completely remove all GiveWP data. This includes all GiveWP settings, forms, form meta, donor, donor data, donations. Everything.',
111 'give'),
112 'id' => 'uninstall_on_delete',
113 'type' => 'radio_inline',
114 'default' => 'disabled',
115 'options' => [
116 'enabled' => __('Yes, Remove all data', 'give'),
117 'disabled' => __('No, keep my GiveWP settings and donation data', 'give'),
118 ],
119 ],
120 [
121 'name' => __('Default User Role', 'give'),
122 'desc' => __('Users are given this user role when they opt into creating a WordPress/site account along with their donation.',
123 'give'),
124 'id' => 'donor_default_user_role',
125 'type' => 'select',
126 'default' => 'give_donor',
127 'options' => give_get_donor_safe_user_roles(),
128 ],
129 [
130 /* translators: %s: the_content */
131 'name' => sprintf(__('%s filter', 'give'), '<code>the_content</code>'),
132 /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */
133 'desc' => sprintf(__('This controls whether or not GiveWP legacy form content is treated like WordPress content. Disabling this option means that things like social sharing and other theme- or plugin-added functionality to enhance or append things to content will not be applied to GiveWP legacy form content. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.',
134 'give'), esc_url('https://docs.givewp.com/thecontent-filter'),
135 '<code>the_content</code>'),
136 'id' => 'the_content_filter',
137 'default' => 'enabled',
138 'type' => 'radio_inline',
139 'options' => [
140 'enabled' => __('Enabled', 'give'),
141 'disabled' => __('Disabled', 'give'),
142 ],
143 ],
144 [
145 'name' => __('Script Loading Location', 'give'),
146 'desc' => __('This allows you to load your GiveWP scripts either in the <code>&lt;head&gt;</code> or footer of your website.',
147 'give'),
148 'id' => 'scripts_footer',
149 'type' => 'radio_inline',
150 'default' => 'disabled',
151 'options' => [
152 'disabled' => __('Head', 'give'),
153 'enabled' => __('Footer', 'give'),
154 ],
155 ],
156 [
157 'name' => __('Setup Page', 'give'),
158 /* translators: %s: about page URL */
159 'desc' => sprintf(
160 wp_kses(
161 __(
162 'This option controls the display of the %s when GiveWP is first installed.',
163 'give'
164 ),
165 [
166 'a' => [
167 'href' => [],
168 'target' => [],
169 ],
170 ]
171 ),
172 SetupPage::getSetupPageEnabledOrDisabled(
173 ) === SetupPage::ENABLED ? "<a href='$setupPage' target='_blank'>GiveWP Setup page</a>" : 'GiveWP Setup page'
174 ),
175 'id' => 'setup_page_enabled',
176 'type' => 'radio_inline',
177 'default' => give_is_setting_enabled(
178 SetupPage::getSetupPageEnabledOrDisabled()
179 )
180 ? SetupPage::ENABLED
181 : SetupPage::DISABLED,
182 'options' => [
183 SetupPage::ENABLED => __('Enabled', 'give'),
184 SetupPage::DISABLED => __('Disabled', 'give'),
185 ],
186 'wrapper_class' => version_compare(get_bloginfo('version'), '5.0',
187 '<=') ? 'give-hidden' : null,
188 ],
189 [
190 'name' => __('Form Page URL Prefix', 'give'),
191 'desc' => sprintf(
192 __('This slug is used as a base for the (invisible to users/site visitors) iframe URL that contains all form templates besides the legacy form template. The URL currently looks like this: %1$s. This option allows you to modify that URL to avoid conflicts that might exist with other pages and URLs on the site.',
193 'give'),
194 '<code>' . trailingslashit(home_url()) . Give()->routeForm->getBase() . '/{form-slug}</code>'
195 ),
196 'id' => Give()->routeForm->getOptionName(),
197 'type' => 'text',
198 'default' => Give()->routeForm->getBase(),
199 ],
200 [
201 'name' => __('Advanced Database Updates', 'give'),
202 'desc' => __('This option is only for advanced users and/or those directed by GiveWP support. Once you enable this, you\'ll have the ability to override the run order and to force re-running for database updates at Donations > Tools > Data. If you don\'t know what you are doing, you can easily break things with this option enabled. Do not leave this option enabled after you\'re done troubleshooting.',
203 'give'),
204 'id' => 'enable_database_updates',
205 'type' => 'radio_inline',
206 'default' => 'disabled',
207 'options' => [
208 'enabled' => __('Enabled', 'give'),
209 'disabled' => __('Disabled', 'give'),
210 ],
211 ],
212 [
213 'name' => __('Orphaned Donation Forms', 'give'),
214 'desc' => __('Show orphaned donation forms list-table. Tools > Data > Orphaned forms', 'give'),
215 'id' => 'show_orphaned_forms_table',
216 'type' => 'radio_inline',
217 'default' => 'disabled',
218 'options' => [
219 'enabled' => __('Enabled', 'give'),
220 'disabled' => __('Disabled', 'give'),
221 ],
222 ],
223 [
224 'name' => __('GiveWP Cache', 'give'),
225 'id' => 'give-clear-cache',
226 'buttonTitle' => __('Clear Cache', 'give'),
227 'desc' => __('Click this button if you want to clear GiveWP\'s cache. The plugin stores common settings and queries in cache to optimize performance. Clearing cache will remove and begin rebuilding these saved queries.',
228 'give'),
229 'type' => 'remove_cache_button',
230 ],
231 [
232 'name' => __('Advanced Settings Docs Link', 'give'),
233 'id' => 'advanced_settings_docs_link',
234 'url' => esc_url('http://docs.givewp.com/settings-advanced'),
235 'title' => __('Advanced Settings', 'give'),
236 'type' => 'give_docs_link',
237 ],
238 [
239 'id' => 'give_title_data_control_2',
240 'type' => 'sectionend',
241 ],
242 ];
243 break;
244
245 case 'donation-forms':
246 $settings = [
247 [
248 'id' => 'give_setting_advanced_section_donation_forms',
249 'type' => 'title',
250 ],
251 [
252 'name' => __('Custom Styles', 'give'),
253 'desc' => __(
254 'Add your own custom CSS styles here to customize the appearance of all donation forms across your site. These styles will be applied globally, allowing you to maintain consistent design without editing each form individually.',
255 'give'
256 ),
257 'id' => 'custom_form_styles',
258 'type' => 'code_editor',
259 'css' => 'width: 100%;',
260 'editor_attributes' => [
261 'mode' => 'css',
262 ],
263 ],
264 [
265 'id' => 'give_setting_advanced_section_donation_forms',
266 'type' => 'sectionend',
267 ],
268 ];
269 break;
270
271 case 'akismet-spam-protection':
272 $settings = [
273 [
274 'id' => 'give_setting_advanced_section_akismet_spam_protection',
275 'type' => 'title',
276 ],
277 [
278 'name' => __('Akismet SPAM Protection', 'give'),
279 'desc' => __('Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent through Akismet\'s SPAM check API if you have the plugin activated and configured.',
280 'give'),
281 'id' => 'akismet_spam_protection',
282 'type' => 'radio_inline',
283 'default' => (give_check_akismet_key()) ? 'enabled' : 'disabled',
284 'options' => [
285 'enabled' => __('Enabled', 'give'),
286 'disabled' => __('Disabled', 'give'),
287 ],
288 ],
289 [
290 'name' => __('Whitelist by Email', 'give'),
291 'desc' => sprintf(
292 '%1$s %2$s',
293 __('Add emails one at a time to ensure that donations using that email bypass GiveWP\'s Akismet SPAM filtering. Emails added to the list here are always allowed to donate, even if they\'ve been flagged by Akismet.',
294 'give'),
295 sprintf(
296 __('To permanently prevent emails from being flagged as SPAM by Akismet <a href="%1$s" target="_blank">contact their team here</a>.',
297 'give'),
298 esc_url('https://docs.givewp.com/akismet-contact')
299 )
300 ),
301 'id' => 'akismet_whitelisted_email_addresses',
302 'type' => 'email',
303 'attributes' => [
304 'placeholder' => 'test@example.com',
305 ],
306 'repeat' => true,
307 'repeat_btn_title' => esc_html__('Add Email', 'give'),
308 ],
309 [
310 'id' => 'give_setting_advanced_section_akismet_spam_protection',
311 'type' => 'sectionend',
312 ],
313 ];
314 break;
315 }
316
317 /**
318 * Hide caching setting by default.
319 *
320 * @since 2.0
321 */
322 if (apply_filters('give_settings_advanced_show_cache_setting', false)) {
323 array_splice(
324 $settings,
325 1,
326 0,
327 [
328 [
329 'name' => __('Cache', 'give'),
330 'desc' => __('If caching is enabled the plugin will start caching custom post type related queries and reduce the overall load time.',
331 'give'),
332 'id' => 'cache',
333 'type' => 'radio_inline',
334 'default' => 'enabled',
335 'options' => [
336 'enabled' => __('Enabled', 'give'),
337 'disabled' => __('Disabled', 'give'),
338 ],
339 ],
340 ]
341 );
342 }
343
344 /**
345 * Filter the advanced settings.
346 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
347 */
348 $settings = apply_filters('give_settings_advanced', $settings);
349
350 /**
351 * Filter the settings.
352 *
353 * @since 1.8
354 *
355 * @param array $settings
356 *
357 */
358 $settings = apply_filters('give_get_settings_' . $this->id, $settings);
359
360 // Output.
361 return $settings;
362 }
363
364 /**
365 * Get sections.
366 *
367 * @since 1.8
368 * @return array
369 */
370 public function get_sections()
371 {
372 $sections = [
373 'advanced-options' => __('Advanced Options', 'give'),
374 'donation-forms' => __('Donation Forms', 'give'),
375 'akismet-spam-protection' => __('Akismet SPAM Protection', 'give'),
376 ];
377
378 return apply_filters('give_get_sections_' . $this->id, $sections);
379 }
380
381
382 /**
383 * Render remove_cache_button field type
384 *
385 * @since 2.25.2 add nonce field
386 * @since 2.1
387 * @access public
388 *
389 * @param array $field
390 *
391 */
392 public function render_remove_cache_button($field)
393 {
394 ?>
395 <tr valign="top" <?php
396 echo ! empty($field['wrapper_class']) ? 'class="' . $field['wrapper_class'] . '"' : ''; ?>>
397 <th scope="row" class="titledesc">
398 <label
399 for="<?php
400 echo esc_attr($field['id']); ?>"><?php
401 echo esc_html($field['name']); ?></label>
402 </th>
403 <td class="give-forminp">
404 <button type="button" id="<?php
405 echo esc_attr($field['id']); ?>"
406 class="button button-secondary"><?php
407 echo esc_html($field['buttonTitle']); ?></button>
408 <?php
409 echo Give_Admin_Settings::get_field_description($field ); ?>
410 <?php wp_nonce_field('give_cache_flush', 'give_cache_flush_nonce'); ?>
411 </td>
412 </tr>
413 <?php
414 }
415
416
417 /**
418 * Validate setting
419 *
420 * @since 2.2.0
421 * @access public
422 *
423 * @param array $options
424 *
425 */
426 public function validate_settngs($options)
427 {
428 // Sanitize data.
429 $akismet_spam_protection = isset($options['akismet_spam_protection'])
430 ? $options['akismet_spam_protection']
431 : (give_check_akismet_key() ? 'enabled' : 'disabled');
432
433 // Show error message if Akismet not configured and Admin try to save 'enabled' option.
434 if (
435 give_is_setting_enabled($akismet_spam_protection)
436 && ! give_check_akismet_key()
437 ) {
438 Give_Admin_Settings::add_error(
439 'give-akismet-protection',
440 __('Please properly configure Akismet to enable SPAM protection.', 'give')
441 );
442
443 give_update_option('akismet_spam_protection', 'disabled' );
444 }
445 }
446
447 public function sanitize_option_donor_default_user_role($value) {
448 $baseRole = ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' );
449 $defaultUserRoles = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', $baseRole ) );
450 if(!current_user_can('manage_options')){
451 if('administrator' === $value) {
452 if(!in_array('administrator', $defaultUserRoles)) {
453 $value = $baseRole;
454 }
455 }
456 }
457
458 return $value;
459 }
460
461 /**
462 * @since 3.18.0
463 */
464 public function _render_give_based_form_editor_notice($field, $value)
465 {
466 if (OptionBasedFormEditor::isEnabled()) {
467 ?>
468 <tr valign="top" <?php
469 echo ! empty($field['wrapper_class']) ? 'class="' . $field['wrapper_class'] . '"' : ''; ?>>
470 <th scope="row" class="titledesc">
471 </th>
472 <td class="give-forminp">
473 <div class="give_option_based_form_editor_notice">
474 <svg width="20" height="20" viewBox="0 0 20 20" fill="none"
475 xmlns="http://www.w3.org/2000/svg">
476 <path fill-rule="evenodd" clip-rule="evenodd"
477 d="M10.678 1.39a1.667 1.667 0 0 0-1.355 0c-.333.148-.549.409-.7.621-.147.21-.306.483-.48.784l-6.89 11.9c-.174.301-.333.576-.441.809-.11.237-.228.555-.19.918.048.47.295.898.677 1.176.295.214.63.271.89.295.256.023.573.023.922.023H16.89c.349 0 .666 0 .922-.023.26-.024.594-.08.89-.295.382-.278.628-.706.677-1.176.038-.363-.08-.681-.19-.918a10.943 10.943 0 0 0-.442-.81l-6.89-11.9a10.856 10.856 0 0 0-.48-.783c-.15-.212-.367-.473-.7-.621zm.156 6.11a.833.833 0 0 0-1.667 0v3.333a.833.833 0 0 0 1.667 0V7.5zM10 13.333A.833.833 0 0 0 10 15h.009a.833.833 0 0 0 0-1.667H10z"
478 fill="#F29718" />
479 </svg>
480 <p>
481 <?php
482 echo esc_html__('We recommend moving away from Legacy settings and the Option-Based Editor as they are not compatible with newer features and will eventually be removed.',
483 'give'); ?>
484 </p>
485 </div>
486 </td>
487 </tr>
488 <?php
489 }
490 }
491 }
492
493 endif;
494
495 return new Give_Settings_Advanced();
496