PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.6.0
GiveWP – Donation Plugin and Fundraising Platform v2.6.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-advanced.php
give / includes / admin / settings Last commit date
class-settings-addon.php 6 years ago class-settings-advanced.php 6 years ago class-settings-display.php 6 years ago class-settings-email.php 6 years ago class-settings-gateways.php 6 years ago class-settings-general.php 6 years ago class-settings-license.php 6 years ago
class-settings-advanced.php
325 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 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly
14 }
15
16 if ( ! class_exists( 'Give_Settings_Advanced' ) ) :
17
18 /**
19 * Give_Settings_Advanced.
20 *
21 * @sine 1.8
22 */
23 class Give_Settings_Advanced extends Give_Settings_Page {
24
25 /**
26 * Constructor.
27 */
28 public function __construct() {
29 $this->id = 'advanced';
30 $this->label = __( 'Advanced', 'give' );
31
32 $this->default_tab = 'advanced-options';
33
34 if ( $this->id === give_get_current_setting_tab() ) {
35 add_action( 'give_admin_field_remove_cache_button', array(
36 $this,
37 'render_remove_cache_button'
38 ), 10, 1 );
39 add_action( 'give_save_settings_give_settings', array( $this, 'validate_settngs' ) );
40 }
41
42 parent::__construct();
43 }
44
45 /**
46 * Get settings array.
47 *
48 * @return array
49 * @since 1.8
50 */
51 public function get_settings() {
52 $settings = array();
53
54 $current_section = give_get_current_setting_section();
55
56 switch ( $current_section ) {
57 case 'advanced-options':
58 $settings = array(
59 array(
60 'id' => 'give_title_data_control_2',
61 'type' => 'title',
62 ),
63 array(
64 'name' => __( 'Remove Data on Uninstall', 'give' ),
65 'desc' => __( 'When the plugin is deleted, completely remove all GiveWP data. This includes all GiveWP settings, forms, form meta, donor, donor data, donations. Everything.', 'give' ),
66 'id' => 'uninstall_on_delete',
67 'type' => 'radio_inline',
68 'default' => 'disabled',
69 'options' => array(
70 'enabled' => __( 'Yes, Remove all data', 'give' ),
71 'disabled' => __( 'No, keep my GiveWP settings and donation data', 'give' ),
72 ),
73 ),
74 array(
75 'name' => __( 'Default User Role', 'give' ),
76 'desc' => __( 'Assign default user roles for donors when donors opt to register as a WP User.', 'give' ),
77 'id' => 'donor_default_user_role',
78 'type' => 'select',
79 'default' => 'give_donor',
80 'options' => give_get_user_roles(),
81 ),
82 array(
83 /* translators: %s: the_content */
84 'name' => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ),
85 /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */
86 '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>' ),
87 'id' => 'the_content_filter',
88 'default' => 'enabled',
89 'type' => 'radio_inline',
90 'options' => array(
91 'enabled' => __( 'Enabled', 'give' ),
92 'disabled' => __( 'Disabled', 'give' ),
93 ),
94 ),
95 array(
96 'name' => __( 'Script Loading Location', 'give' ),
97 'desc' => __( 'This allows you to load your GiveWP scripts either in the <code>&lt;head&gt;</code> or footer of your website.', 'give' ),
98 'id' => 'scripts_footer',
99 'type' => 'radio_inline',
100 'default' => 'disabled',
101 'options' => array(
102 'disabled' => __( 'Head', 'give' ),
103 'enabled' => __( 'Footer', 'give' ),
104 ),
105 ),
106 array(
107 'name' => __( 'Babel Polyfill Script', 'give' ),
108 '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' ),
109 'id' => 'babel_polyfill_script',
110 'type' => 'radio_inline',
111 'default' => 'enabled',
112 'options' => array(
113 'enabled' => __( 'Enabled', 'give' ),
114 'disabled' => __( 'Disabled', 'give' ),
115 ),
116 ),
117 array(
118 'name' => __( 'Welcome Screen', 'give' ),
119 /* translators: %s: about page URL */
120 'desc' => sprintf(
121 wp_kses(
122 __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">GiveWP Welcome screen</a> that displays each time GiveWP is activated or updated.', 'give' ),
123 array(
124 'a' => array(
125 'href' => array(),
126 'target' => array(),
127 ),
128 )
129 ),
130 esc_url( admin_url( 'index.php?page=give-getting-started' ) )
131 ),
132 'id' => 'welcome',
133 'type' => 'radio_inline',
134 'default' => 'enabled',
135 'options' => array(
136 'enabled' => __( 'Enabled', 'give' ),
137 'disabled' => __( 'Disabled', 'give' ),
138 ),
139 ),
140 array(
141 'name' => 'GiveWP Cache',
142 'id' => 'give-clear-cache',
143 'buttonTitle' => __( 'Clear Cache', 'give' ),
144 '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' ),
145 'type' => 'remove_cache_button',
146 ),
147 array(
148 'name' => __( 'Advanced Settings Docs Link', 'give' ),
149 'id' => 'advanced_settings_docs_link',
150 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ),
151 'title' => __( 'Advanced Settings', 'give' ),
152 'type' => 'give_docs_link',
153 ),
154 array(
155 'id' => 'give_title_data_control_2',
156 'type' => 'sectionend',
157 ),
158 );
159 break;
160
161 case 'akismet-spam-protection':
162 $settings = array(
163 array(
164 'id' => 'give_setting_advanced_section_akismet_spam_protection',
165 'type' => 'title',
166 ),
167 array(
168 'name' => __( 'Akismet SPAM Protection', 'give' ),
169 '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.', 'give' ),
170 'id' => 'akismet_spam_protection',
171 'type' => 'radio_inline',
172 'default' => ( give_check_akismet_key() ) ? 'enabled' : 'disabled',
173 'options' => array(
174 'enabled' => __( 'Enabled', 'give' ),
175 'disabled' => __( 'Disabled', 'give' ),
176 ),
177 ),
178 array(
179 'name' => __( 'Whitelist by Email', 'give' ),
180 'desc' => sprintf(
181 '%1$s %2$s',
182 __( '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.', 'give' ),
183 sprintf(
184 __( 'To permanently prevent emails from being flagged as SPAM by Akismet <a href="%1$s" target="_blank">contact their team here</a>.', 'give' ),
185 esc_url( 'https://akismet.com/contact/' )
186 )
187 ),
188 'id' => 'akismet_whitelisted_email_addresses',
189 'type' => 'email',
190 'attributes' => array(
191 'placeholder' => 'jon@email.com',
192 ),
193 'repeat' => true,
194 'repeat_btn_title' => esc_html__( 'Add Email', 'give' ),
195 ),
196 array(
197 'id' => 'give_setting_advanced_section_akismet_spam_protection',
198 'type' => 'sectionend',
199 ),
200 );
201 break;
202 }
203
204 /**
205 * Hide caching setting by default.
206 *
207 * @since 2.0
208 */
209 if ( apply_filters( 'give_settings_advanced_show_cache_setting', false ) ) {
210 array_splice(
211 $settings,
212 1,
213 0,
214 array(
215 array(
216 'name' => __( 'Cache', 'give' ),
217 'desc' => __( 'If caching is enabled the plugin will start caching custom post type related queries and reduce the overall load time.', 'give' ),
218 'id' => 'cache',
219 'type' => 'radio_inline',
220 'default' => 'enabled',
221 'options' => array(
222 'enabled' => __( 'Enabled', 'give' ),
223 'disabled' => __( 'Disabled', 'give' ),
224 ),
225 ),
226 )
227 );
228 }
229
230 /**
231 * Filter the advanced settings.
232 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
233 */
234 $settings = apply_filters( 'give_settings_advanced', $settings );
235
236 /**
237 * Filter the settings.
238 *
239 * @param array $settings
240 *
241 * @since 1.8
242 *
243 */
244 $settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
245
246 // Output.
247 return $settings;
248 }
249
250 /**
251 * Get sections.
252 *
253 * @return array
254 * @since 1.8
255 */
256 public function get_sections() {
257 $sections = array(
258 'advanced-options' => __( 'Advanced Options', 'give' ),
259 'akismet-spam-protection' => __( 'Akismet SPAM Protection', 'give' ),
260 );
261
262 return apply_filters( 'give_get_sections_' . $this->id, $sections );
263 }
264
265
266 /**
267 * Render remove_cache_button field type
268 *
269 * @param array $field
270 *
271 * @since 2.1
272 * @access public
273 *
274 */
275 public function render_remove_cache_button( $field ) {
276 ?>
277 <tr valign="top" <?php echo ! empty( $field['wrapper_class'] ) ? 'class="' . $field['wrapper_class'] . '"' : ''; ?>>
278 <th scope="row" class="titledesc">
279 <label
280 for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo esc_html( $field['name'] ); ?></label>
281 </th>
282 <td class="give-forminp">
283 <button type="button" id="<?php echo esc_attr( $field['id'] ); ?>"
284 class="button button-secondary"><?php echo esc_html( $field['buttonTitle'] ); ?></button>
285 <?php echo Give_Admin_Settings::get_field_description( $field ); ?>
286 </td>
287 </tr>
288 <?php
289 }
290
291
292 /**
293 * Validate setting
294 *
295 * @param array $options
296 *
297 * @since 2.2.0
298 * @access public
299 *
300 */
301 public function validate_settngs( $options ) {
302 // Sanitize data.
303 $akismet_spam_protection = isset( $options['akismet_spam_protection'] )
304 ? $options['akismet_spam_protection']
305 : ( give_check_akismet_key() ? 'enabled' : 'disabled' );
306
307 // Show error message if Akismet not configured and Admin try to save 'enabled' option.
308 if (
309 give_is_setting_enabled( $akismet_spam_protection )
310 && ! give_check_akismet_key()
311 ) {
312 Give_Admin_Settings::add_error(
313 'give-akismet-protection',
314 __( 'Please properly configure Akismet to enable SPAM protection.', 'give' )
315 );
316
317 give_update_option( 'akismet_spam_protection', 'disabled' );
318 }
319 }
320 }
321
322 endif;
323
324 return new Give_Settings_Advanced();
325