PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.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 All 256 releases
← All changes | includes/admin/settings/class-settings-advanced.php +455 -219 2.3.14.17.0 View file →
@@ -8,252 +8,488 @@
8 8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9 * @since 1.8
10 10 */
11 11
12 +use Give\FeatureFlags\OptionBasedFormEditor\OptionBasedFormEditor;
13 +use Give\Onboarding\Setup\Page as SetupPage;
14 +
12 15 if ( ! defined( 'ABSPATH' ) ) {
13 - exit; // Exit if accessed directly
16 + exit; // Exit if accessed directly
14 17 }
15 18
16 19 if ( ! class_exists( 'Give_Settings_Advanced' ) ) :
17 20
18 - /**
19 - * Give_Settings_Advanced.
20 - *
21 - * @sine 1.8
22 - */
23 - class Give_Settings_Advanced extends Give_Settings_Page {
21 + /**
22 + * Give_Settings_Advanced.
23 + *
24 + * @sine 1.8
25 + */
26 + class Give_Settings_Advanced extends Give_Settings_Page
27 + {
24 28
25 - /**
26 - * Constructor.
27 - */
28 - public function __construct() {
29 - $this->id = 'advanced';
30 - $this->label = __( 'Advanced', 'give' );
29 + /**
30 + * Constructor.
31 + */
32 + public function __construct()
33 + {
34 + $this->id = 'advanced';
35 + $this->label = __('Advanced', 'give');
31 36
32 - $this->default_tab = 'advanced-options';
37 + $this->default_tab = 'advanced-options';
33 38
34 - if ( $this->id === give_get_current_setting_tab() ) {
35 - add_action( 'give_admin_field_remove_cache_button', array( $this, 'render_remove_cache_button' ), 10, 1 );
36 - add_action( 'give_save_settings_give_settings', array( $this, 'validate_settngs' ) );
37 - }
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 + }
38 54
39 - parent::__construct();
40 - }
55 + parent::__construct();
56 + }
41 57
42 - /**
43 - * Get settings array.
44 - *
45 - * @since 1.8
46 - * @return array
47 - */
48 - public function get_settings() {
49 - $settings = array();
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 = [];
50 69
51 - $current_section = give_get_current_setting_section();
70 + $current_section = give_get_current_setting_section();
71 + $setupPage = esc_url(admin_url('edit.php?post_type=give_forms&page=give-setup'));
52 72
53 - switch ( $current_section ) {
54 - case 'advanced-options':
55 - $settings = array(
56 - array(
57 - 'id' => 'give_title_data_control_2',
58 - 'type' => 'title',
59 - ),
60 - array(
61 - 'name' => __( 'Remove Data on Uninstall', 'give' ),
62 - 'desc' => __( 'When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give' ),
63 - 'id' => 'uninstall_on_delete',
64 - 'type' => 'radio_inline',
65 - 'default' => 'disabled',
66 - 'options' => array(
67 - 'enabled' => __( 'Yes, Remove all data', 'give' ),
68 - 'disabled' => __( 'No, keep my Give settings and donation data', 'give' ),
69 - ),
70 - ),
71 - array(
72 - 'name' => __( 'Default User Role', 'give' ),
73 - 'desc' => __( 'Assign default user roles for donors when donors opt to register as a WP User.', 'give' ),
74 - 'id' => 'donor_default_user_role',
75 - 'type' => 'select',
76 - 'default' => 'give_donor',
77 - 'options' => give_get_user_roles(),
78 - ),
79 - array(
80 - /* translators: %s: the_content */
81 - 'name' => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ),
82 - /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */
83 - 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ),
84 - 'id' => 'the_content_filter',
85 - 'default' => 'enabled',
86 - 'type' => 'radio_inline',
87 - 'options' => array(
88 - 'enabled' => __( 'Enabled', 'give' ),
89 - 'disabled' => __( 'Disabled', 'give' ),
90 - ),
91 - ),
92 - array(
93 - 'name' => __( 'Script Loading Location', 'give' ),
94 - 'desc' => __( 'This allows you to load your Give scripts either in the <code>&lt;head&gt;</code> or footer of your website.', 'give' ),
95 - 'id' => 'scripts_footer',
96 - 'type' => 'radio_inline',
97 - 'default' => 'disabled',
98 - 'options' => array(
99 - 'disabled' => __( 'Head', 'give' ),
100 - 'enabled' => __( 'Footer', 'give' ),
101 - ),
102 - ),
103 - array(
104 - 'name' => __( 'Babel Polyfill Script', 'give' ),
105 - 'desc' => __( 'Decide whether to load the Babel polyfill, which provides backwards compatibility for older browsers such as IE 11. The polyfill may be disabled to avoid conflicts with other themes or plugins that load the same script.', 'give' ),
106 - 'id' => 'babel_polyfill_script',
107 - 'type' => 'radio_inline',
108 - 'default' => 'enabled',
109 - 'options' => array(
110 - 'enabled' => __( 'Enabled', 'give' ),
111 - 'disabled' => __( 'Disabled', 'give' ),
112 - ),
113 - ),
114 - array(
115 - 'name' => __( 'Akismet SPAM Protection', 'give' ),
116 - 'desc' => __( 'Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent to Akismet\'s API if you have the plugin activated and configured.', 'give' ),
117 - 'id' => 'akismet_spam_protection',
118 - 'type' => 'radio_inline',
119 - 'default' => ( give_check_akismet_key() ) ? 'enabled' : 'disabled',
120 - 'options' => array(
121 - 'enabled' => __( 'Enabled', 'give' ),
122 - 'disabled' => __( 'Disabled', 'give' ),
123 - ),
124 - ),
125 - array(
126 - 'name' => 'Give Cache',
127 - 'id' => 'give-clear-cache',
128 - 'buttonTitle' => __( 'Clear Cache', 'give' ),
129 - 'desc' => __( 'Click this button if you want to clear Give\'s cache. The plugin stores common settings and queries in cache to optimize performance. Clearing cache will remove and begin rebuilding these saved queries.', 'give' ),
130 - 'type' => 'remove_cache_button'
131 - ),
132 - array(
133 - 'name' => __( 'Advanced Settings Docs Link', 'give' ),
134 - 'id' => 'advanced_settings_docs_link',
135 - 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ),
136 - 'title' => __( 'Advanced Settings', 'give' ),
137 - 'type' => 'give_docs_link',
138 - ),
139 - array(
140 - 'id' => 'give_title_data_control_2',
141 - 'type' => 'sectionend',
142 - ),
143 - );
144 - break;
145 - }
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;
146 244
147 - /**
148 - * Hide caching setting by default.
149 - *
150 - * @since 2.0
151 - */
152 - if ( apply_filters( 'give_settings_advanced_show_cache_setting', false ) ) {
153 - array_splice( $settings, 1, 0, array(
154 - array(
155 - 'name' => __( 'Cache', 'give' ),
156 - 'desc' => __( 'If caching is enabled the plugin will start caching custom post type related queries and reduce the overall load time.', 'give' ),
157 - 'id' => 'cache',
158 - 'type' => 'radio_inline',
159 - 'default' => 'enabled',
160 - 'options' => array(
161 - 'enabled' => __( 'Enabled', 'give' ),
162 - 'disabled' => __( 'Disabled', 'give' ),
163 - ),
164 - )
165 - ) );
166 - }
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;
167 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' => '[email protected]',
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 + }
168 316
169 - /**
170 - * Filter the advanced settings.
171 - * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
172 - */
173 - $settings = apply_filters( 'give_settings_advanced', $settings );
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 + }
174 343
175 - /**
176 - * Filter the settings.
177 - *
178 - * @since 1.8
179 - *
180 - * @param array $settings
181 - */
182 - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
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);
183 349
184 - // Output.
185 - return $settings;
186 - }
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);
187 359
188 - /**
189 - * Get sections.
190 - *
191 - * @since 1.8
192 - * @return array
193 - */
194 - public function get_sections() {
195 - $sections = array(
196 - 'advanced-options' => __( 'Advanced Options', 'give' ),
197 - );
360 + // Output.
361 + return $settings;
362 + }
198 363
199 - return apply_filters( 'give_get_sections_' . $this->id, $sections );
200 - }
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 + ];
201 377
378 + return apply_filters('give_get_sections_' . $this->id, $sections);
379 + }
202 380
203 - /**
204 - * Render remove_cache_button field type
205 - *
206 - * @since 2.1
207 - * @access public
208 - *
209 - * @param array $field
210 - */
211 - public function render_remove_cache_button( $field ) {
212 - ?>
213 - <tr valign="top" <?php echo ! empty( $field['wrapper_class'] ) ? 'class="' . $field['wrapper_class'] . '"' : '' ?>>
214 - <th scope="row" class="titledesc">
215 - <label
216 - for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo esc_html( $field['name'] ) ?></label>
217 - </th>
218 - <td class="give-forminp">
219 - <button type="button" id="<?php echo esc_attr( $field['id'] ); ?>"
220 - class="button button-secondary"><?php echo esc_html( $field['buttonTitle'] ) ?></button>
221 - <?php echo Give_Admin_Settings::get_field_description( $field ); ?>
222 - </td>
223 - </tr>
224 - <?php
225 - }
226 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 + }
227 415
228 - /**
229 - * Validate setting
230 - *
231 - * @since 2.2.0
232 - * @access public
233 - *
234 - * @param array $options
235 - */
236 - public function validate_settngs( $options ) {
237 - // Sanitize data.
238 - $akismet_spam_protection = isset( $options['akismet_spam_protection'] )
239 - ? $options['akismet_spam_protection']
240 - : ( give_check_akismet_key() ? 'enabled' : 'disabled' );
241 416
242 - // Show error message if Akismet not configured and Admin try to save 'enabled' option.
243 - if (
244 - give_is_setting_enabled( $akismet_spam_protection )
245 - && ! give_check_akismet_key()
246 - ) {
247 - Give_Admin_Settings::add_error(
248 - 'give-akismet-protection',
249 - __( 'Please properly configure Akismet to enable SPAM protection.', 'give' )
250 - );
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');
251 432
252 - give_update_option( 'akismet_spam_protection', 'disabled' );
253 - }
254 - }
255 - }
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 + }
256 492
257 493 endif;
258 494
259 495 return new Give_Settings_Advanced();