PluginProbe
Contact Forms by Cimatti / 2.2.32
Contact Forms by Cimatti v2.2.32
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
contact-forms / admin / settings-page.php

settings-page.php in Contact Forms by Cimatti 2.2.32, at admin/settings-page.php

707 lines 44.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3
4 function accua_forms_settings_page_head_scripts() {
5 wp_enqueue_style('wp-color-picker');
6 wp_enqueue_script('wp-color-picker');
7
8 // Enqueue settings page JavaScript
9 wp_enqueue_script('contact_forms_tabs', plugins_url('assets/js/admin/tabs.js', ACCUA_FORMS_FILE), array('jquery'), ACCUA_FORMS_JS_VERSION, true);
10 wp_enqueue_script('accua-forms-settings-page', plugins_url('assets/js/admin/settings-page.js', ACCUA_FORMS_FILE), array('jquery', 'contact_forms_tabs'), ACCUA_FORMS_JS_VERSION, true);
11
12 // Theme Helper tab scripts
13 wp_enqueue_script(
14 'accua-forms-theme-helper',
15 plugins_url('assets/js/admin/theme-helper.js', ACCUA_FORMS_FILE),
16 array('jquery'),
17 ACCUA_FORMS_JS_VERSION,
18 true
19 );
20 wp_localize_script('accua-forms-theme-helper', 'accuaThemeHelper', array(
21 'ajaxUrl' => admin_url('admin-ajax.php'),
22 'nonce' => wp_create_nonce('accua_theme_helper'),
23 'pluginCssUrl' => plugins_url('assets/css/frontend.css', ACCUA_FORMS_FILE),
24 'i18n' => array(
25 'scanning' => __('Scanning...', 'contact-forms'),
26 'noConflicts' => __('No CSS conflicts detected!', 'contact-forms'),
27 'conflictsFound' => __('CSS conflicts found:', 'contact-forms'),
28 'scanComplete' => __('Scan complete', 'contact-forms'),
29 'scanError' => __('Error scanning URL', 'contact-forms'),
30 'enterUrl' => __('Enter a URL to scan', 'contact-forms'),
31 'fetchingCss' => __('Fetching CSS from URL...', 'contact-forms'),
32 ),
33 'monitoredClasses' => accua_forms_get_monitored_css_classes(),
34 'criticalProperties' => array(
35 'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
36 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
37 'display', 'position', 'visibility', 'overflow',
38 'width', 'height', 'min-width', 'min-height', 'max-width', 'max-height',
39 'flex', 'flex-direction', 'flex-wrap', 'align-items', 'justify-content',
40 'border', 'border-width', 'border-style',
41 'float', 'clear', 'z-index', 'opacity',
42 ),
43 ));
44
45 // Localize script with AJAX URL, nonce, and translations
46 wp_localize_script('accua-forms-settings-page', 'accuaFormsSettings', array(
47 'ajaxUrl' => admin_url('admin-ajax.php'),
48 'nonce' => wp_create_nonce('accua_forms_restore_default'),
49 'dangerNonce' => wp_create_nonce('accua_forms_danger_zone'),
50 'siteDomain' => wp_parse_url( home_url(), PHP_URL_HOST ),
51 'i18n' => array(
52 'confirmRestore' => __('Are you sure you want to restore the default value for this message? This will overwrite your current content.', 'contact-forms'),
53 'restoring' => __('Restoring...', 'contact-forms'),
54 'restored' => __('Restored!', 'contact-forms'),
55 'error' => __('Error restoring default', 'contact-forms'),
56 'restoreDefault' => __('Restore default', 'contact-forms'),
57 'anonymizing' => __('Anonymizing...', 'contact-forms'),
58 'loading' => __('Loading...', 'contact-forms'),
59 'deleting' => __('Deleting...', 'contact-forms'),
60 'noSubmissionsFound' => __('No submissions found matching the specified period.', 'contact-forms'),
61 /* translators: %d: total number of submissions that will be anonymized */
62 'previewHeading' => __('The following %d submissions will be anonymized:', 'contact-forms'),
63 'formColumn' => __('Form', 'contact-forms'),
64 'submissionsColumn' => __('Submissions', 'contact-forms'),
65 'totalLabel' => __('Total', 'contact-forms'),
66 'confirmAnonymize' => __('Confirm anonymization', 'contact-forms'),
67 'cancel' => __('Cancel', 'contact-forms'),
68 'confirmDeletePrompt' => sprintf(
69 /* translators: %s: site domain */
70 __( 'This will permanently delete ALL Contact Forms data (settings, forms, submissions, uploaded files). This cannot be undone. Type "%s" to confirm:', 'contact-forms' ),
71 wp_parse_url( home_url(), PHP_URL_HOST )
72 ),
73 ),
74 ));
75 }
76
77 function accua_forms_settings_page() {
78 ?>
79 <div id="accua_forms_settings_page" class="accua_forms_admin_page wrap">
80 <h1><?php esc_html_e('Contact Forms - Default Settings', 'contact-forms'); ?></h1>
81 <?php
82 $empty_form_data = array(
83 'success_message' => '',
84 'error_message' => '',
85 'emails_from_name' => '',
86 'emails_from' => '',
87 'admin_emails_to' => '',
88 'emails_bcc' => '',
89 'admin_emails_subject' => '',
90 'admin_emails_message' => '',
91 'confirmation_emails_subject' => '',
92 'confirmation_emails_message' => '',
93 'layout' => 'sidebyside',
94 'style_margin' => '',
95 'style_border_color' => '',
96 'style_border_width' => '',
97 'style_border_radius' => '',
98 'style_background_color' => '',
99 'style_padding' => '',
100 'style_color' => '',
101 'style_font_size' => '',
102 'style_field_spacing' => '',
103 'style_field_border_color' => '',
104 'style_field_border_width' => '',
105 'style_field_border_radius' => '',
106 'style_field_background_color' => '',
107 'style_field_padding' => '',
108 'style_field_color' => '',
109 'style_submit_border_color' => '',
110 'style_submit_border_width' => '',
111 'style_submit_border_radius' => '',
112 'style_submit_background_color' => '',
113 'style_submit_padding' => '',
114 'style_submit_color' => '',
115 'style_submit_font_size' => '',
116 );
117
118 $empty_file_data = array(
119 'valid_extensions' => '',
120 'max_size' => '',
121 'dest_path' => '',
122 );
123
124 $empty_captcha_data = array(
125 'recaptcha_force_v1' => '',
126 'recaptcha_public_key' => '',
127 'recaptcha_private_key' => '',
128 );
129
130 $empty_analytics_data = array(
131 'analytics_track_submit' => false,
132 'analytics_track_fields' => false,
133 );
134
135 $empty_anonymize_ip_data = array(
136 'anonymize_ip_bytes' => 0,
137 );
138
139 $empty_retention_data = array(
140 'retention_value' => 0,
141 'retention_unit' => 'months',
142 'retention_mode' => 'anonymize',
143 );
144
145 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- REQUEST_METHOD is always set by server
146 if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD'] && ! empty( $_POST['accua_form_save_form_settings'] ) ) {
147 check_admin_referer('accua_form_save_settings', '_nonce_accua_form_save_settings');
148 $post = stripslashes_deep($_POST);
149 $post += $empty_form_data;
150 $post += $empty_file_data;
151 $post += $empty_captcha_data;
152 $post += $empty_analytics_data;
153 $post += $empty_anonymize_ip_data;
154 $post += $empty_retention_data;
155 $form_data = array();
156 $file_data = array();
157 $captcha_data = array();
158 $analytics_data = array();
159 $anonymize_ip_data = array();
160 $retention_data = array();
161 foreach($empty_form_data as $key=>$val){
162 $form_data[$key] = $post[$key];
163 }
164 $form_data = accua_forms_filter_settings($form_data);
165
166 $file_data['valid_extensions'] = accua_forms_filter_extensions($post['valid_extensions']);
167 $file_data['max_size'] = $post['max_size'];
168 if (current_user_can('edit_files') || current_user_can('install_plugins')) {
169 $file_data['dest_path'] = $post['dest_path'];
170 } else {
171 $old_file_data = get_option('accua_forms_default_file_field_data',array());
172 $file_data['dest_path'] = isset($old_file_data['dest_path']) ? $old_file_data['dest_path'] : '';
173 }
174
175 $captcha_data['recaptcha_force_v1'] = (bool) $post['recaptcha_force_v1'];
176 $captcha_data['recaptcha_public_key'] = sanitize_text_field($post['recaptcha_public_key']);
177 $captcha_data['recaptcha_private_key'] = sanitize_text_field($post['recaptcha_private_key']);
178
179 foreach($empty_analytics_data as $key=>$val){
180 $analytics_data[$key] = (bool) $post[$key];
181 }
182
183 $anonymize_ip_bytes = (int) $post['anonymize_ip_bytes'];
184 if ($anonymize_ip_bytes < 0) {
185 $anonymize_ip_bytes = 0;
186 } elseif ($anonymize_ip_bytes > 4) {
187 $anonymize_ip_bytes = 4;
188 }
189 $anonymize_ip_data['anonymize_ip_bytes'] = $anonymize_ip_bytes;
190
191 update_option('accua_forms_default_form_data', $form_data);
192 update_option('accua_forms_default_file_field_data', $file_data);
193 update_option('accua_forms_default_captcha_field_data', $captcha_data);
194 update_option('accua_forms_default_analytics_data', $analytics_data);
195 update_option('accua_forms_anonymize_ip_data', $anonymize_ip_data);
196
197 $retention_data['retention_value'] = max( 0, (int) $post['retention_value'] );
198 $retention_data['retention_unit'] = in_array( $post['retention_unit'], array( 'days', 'months', 'years' ), true ) ? $post['retention_unit'] : 'months';
199 $retention_data['retention_mode'] = in_array( $post['retention_mode'], array( 'anonymize', 'delete' ), true ) ? $post['retention_mode'] : 'anonymize';
200 update_option('accua_forms_retention_data', $retention_data);
201
202 if (!empty($post['delete_previous_ip_values'])) {
203 global $wpdb;
204 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Admin-only IP anonymization action, no caching needed
205 $wpdb->query("UPDATE `{$wpdb->prefix}accua_forms_submissions` SET afs_ip = ''");
206 }
207 } else {
208 $form_data = get_option('accua_forms_default_form_data',array()) + $empty_form_data;
209 $file_data = get_option('accua_forms_default_file_field_data',array()) + $empty_file_data;
210 $captcha_data = get_option('accua_forms_default_captcha_field_data',array()) + $empty_captcha_data;
211 $analytics_data = get_option('accua_forms_default_analytics_data',array()) + $empty_analytics_data;
212 $anonymize_ip_data = get_option('accua_forms_anonymize_ip_data',array()) + $empty_anonymize_ip_data;
213 $retention_data = get_option('accua_forms_retention_data',array()) + $empty_retention_data;
214 }
215 if ($captcha_data['recaptcha_force_v1']) {
216 $captcha_data = $empty_captcha_data;
217 }
218 ?>
219 <form method="post">
220 <?php wp_nonce_field('accua_form_save_settings', '_nonce_accua_form_save_settings'); ?>
221 <input type="hidden" name="accua_form_save_form_settings" value="1" />
222 <div id="accua_settings_tabs" class="accua-tabs accua-tabs--primary" data-default-tab="messages">
223 <div class="accua-tabs__tablist" role="tablist" aria-label="<?php esc_attr_e( 'Settings', 'contact-forms' ); ?>">
224 <button class="accua-tabs__tab" role="tab" data-tab="messages"><?php esc_html_e( 'Default Messages', 'contact-forms' ); ?></button>
225 <button class="accua-tabs__tab" role="tab" data-tab="integrations"><?php esc_html_e( 'Integrations', 'contact-forms' ); ?></button>
226 <button class="accua-tabs__tab" role="tab" data-tab="privacy"><?php esc_html_e( 'Privacy', 'contact-forms' ); ?></button>
227 <button class="accua-tabs__tab" role="tab" data-tab="styling"><?php esc_html_e( 'Layout & Styling', 'contact-forms' ); ?></button>
228 <button class="accua-tabs__tab" role="tab" data-tab="theme_helper"><?php esc_html_e( 'Theme Helper', 'contact-forms' ); ?></button>
229 <?php if ( current_user_can( 'manage_options' ) ) : ?>
230 <button class="accua-tabs__tab" role="tab" data-tab="danger_zone"><?php esc_html_e( 'Danger Zone', 'contact-forms' ); ?></button>
231 <?php endif; ?>
232 <button class="accua-tabs__tab" role="tab" data-tab="tokens"><?php esc_html_e( 'Tokens', 'contact-forms' ); ?></button>
233 </div>
234
235 <div class="accua-tabs__panel" role="tabpanel" data-tab="messages">
236 <?php
237 $email_font_formats =
238 'Arial=arial,helvetica,sans-serif;'
239 . 'Arial Black=arial black,avant garde,sans-serif;'
240 . 'Comic Sans MS=comic sans ms,sans-serif;'
241 . 'Courier New=courier new,courier,monospace;'
242 . 'Georgia=georgia,palatino,serif;'
243 . 'Lucida Sans=lucida sans unicode,lucida grande,sans-serif;'
244 . 'Tahoma=tahoma,arial,helvetica,sans-serif;'
245 . 'Times New Roman=times new roman,times,serif;'
246 . 'Trebuchet MS=trebuchet ms,geneva,sans-serif;'
247 . 'Verdana=verdana,geneva,sans-serif;';
248
249 $settings_editor = array(
250 'teeny' => true,
251 'editor_class' => 'accua_form_value',
252 'tinymce' => array(
253 'toolbar1' => 'fontselect,|,bold,italic,underline,|,bullist,numlist,|,link,unlink',
254 'font_formats' => $email_font_formats,
255 'content_style' => 'body { font-family: arial, helvetica, sans-serif; }',
256 ));
257 ?>
258 <div class="accua-settings-grid">
259
260 <div class="postbox">
261 <div class="postbox-header"><h2><?php esc_html_e('1. On-screen success message', 'contact-forms'); ?></h2></div>
262 <div class="inside">
263 <div id="accua_form_success_message">
264 <?php wp_editor( $form_data['success_message'] , 'success_message' , $settings_editor); ?>
265 </div>
266 <p class="accua-restore-default-wrapper">
267 <button type="button" class="button-link accua-restore-default-btn" data-message-type="success_message">
268 <?php esc_html_e('Restore default', 'contact-forms'); ?>
269 </button>
270 </p>
271 </div></div>
272
273 <div class="postbox">
274 <div class="postbox-header"><h2><?php esc_html_e('2. On-screen error message', 'contact-forms'); ?></h2></div>
275 <div class="inside">
276 <div id="accua_form_error_message">
277 <?php wp_editor( $form_data['error_message'] , 'error_message' , $settings_editor); ?>
278 </div>
279 <p class="accua-restore-default-wrapper">
280 <button type="button" class="button-link accua-restore-default-btn" data-message-type="error_message">
281 <?php esc_html_e('Restore default', 'contact-forms'); ?>
282 </button>
283 </p>
284 </div></div>
285
286 <div class="postbox">
287 <div class="postbox-header"><h2><?php esc_html_e('3. Email to notify administrator', 'contact-forms'); ?></h2></div>
288 <div class="inside">
289 <table class="form-table" role="presentation">
290 <tr>
291 <th scope="row"><label for="accua_settings_admin_emails_to"><?php esc_html_e( 'To', 'contact-forms'); ?></label></th>
292 <td id="accua_form_admin_emails_to"><input id="accua_settings_admin_emails_to" name="admin_emails_to" class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['admin_emails_to']) ?>" /></td>
293 </tr>
294 <tr>
295 <th scope="row"><label for="accua_settings_emails_bcc"><?php esc_html_e( 'Bcc', 'contact-forms'); ?></label></th>
296 <td id="accua_form_emails_bcc"><input id="accua_settings_emails_bcc" name="emails_bcc" class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['emails_bcc']) ?>" /></td>
297 </tr>
298 <tr>
299 <th scope="row"><label for="accua_settings_admin_emails_subject"><?php esc_html_e( 'Subject', 'contact-forms'); ?></label></th>
300 <td id="accua_form_admin_emails_subject"><input id="accua_settings_admin_emails_subject" name="admin_emails_subject" class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['admin_emails_subject']) ?>" /></td>
301 </tr>
302 </table>
303 <div id="accua_form_admin_emails_message">
304 <?php wp_editor( $form_data['admin_emails_message'] , 'admin_emails_message' , $settings_editor); ?>
305 </div>
306 <p class="accua-restore-default-wrapper">
307 <button type="button" class="button-link accua-restore-default-btn" data-message-type="admin_emails">
308 <?php esc_html_e('Restore default', 'contact-forms'); ?>
309 </button>
310 <span class="description"><?php esc_html_e('(Restores subject and message only)', 'contact-forms'); ?></span>
311 </p>
312 </div></div>
313
314 <div class="postbox">
315 <div class="postbox-header"><h2><?php esc_html_e('4. Email confirmation to the person who completed the form', 'contact-forms'); ?></h2></div>
316 <div class="inside">
317 <table class="form-table" role="presentation">
318 <tr>
319 <th scope="row"><label for="accua_settings_emails_from_name"><?php esc_html_e( 'From name', 'contact-forms'); ?></label></th>
320 <td id="accua_form_emails_from_name"><input id="accua_settings_emails_from_name" class="accua_form_value regular-text" name="emails_from_name" type="text" value="<?php echo esc_attr($form_data['emails_from_name']) ?>" /></td>
321 </tr>
322 <tr>
323 <th scope="row"><label for="accua_settings_emails_from"><?php esc_html_e( 'From email', 'contact-forms'); ?></label></th>
324 <td id="accua_form_emails_from"><input id="accua_settings_emails_from" class="accua_form_value regular-text" name="emails_from" type="text" value="<?php echo esc_attr($form_data['emails_from']) ?>" /></td>
325 </tr>
326 <tr>
327 <th scope="row"><label for="accua_settings_confirmation_emails_subject"><?php esc_html_e( 'Subject', 'contact-forms'); ?></label></th>
328 <td id="accua_form_confirmation_emails_subject"><input id="accua_settings_confirmation_emails_subject" class="accua_form_value regular-text" type="text" name="confirmation_emails_subject" value="<?php echo esc_attr($form_data['confirmation_emails_subject']) ?>" /></td>
329 </tr>
330 </table>
331 <div id="accua_form_confirmation_emails_message">
332 <?php wp_editor( $form_data['confirmation_emails_message'] , 'confirmation_emails_message' , $settings_editor); ?>
333 </div>
334 <p class="accua-restore-default-wrapper">
335 <button type="button" class="button-link accua-restore-default-btn" data-message-type="confirmation_emails">
336 <?php esc_html_e('Restore default', 'contact-forms'); ?>
337 </button>
338 <span class="description"><?php esc_html_e('(Restores subject and message only)', 'contact-forms'); ?></span>
339 </p>
340 </div></div>
341
342 </div>
343 </div><!-- /panel: messages -->
344
345 <div class="accua-tabs__panel" role="tabpanel" data-tab="integrations">
346 <div class="accua-settings-grid">
347
348 <div class="postbox">
349 <div class="postbox-header"><h2><?php esc_html_e( 'File upload default settings', 'contact-forms'); ?></h2></div>
350 <div class="inside">
351 <div id="accua_form_valid_extensions"><?php esc_html_e( 'Valid extensions', 'contact-forms'); ?> <br /><textarea name="valid_extensions" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo esc_textarea($file_data['valid_extensions']) ?></textarea>
352 <small><?php esc_html_e( 'List of valid extensions, without dot, one per line.', 'contact-forms'); ?></small>
353 </div>
354 <div id="accua_form_max_size"><?php esc_html_e( 'Maximum file size:', 'contact-forms'); ?> <input name="max_size" class="accua_form_value" type="text" value="<?php echo esc_attr($file_data['max_size']) ?>" /><br />
355 <small><?php esc_html_e( 'You can use suffix K, M or G for kilobyte, megabyte or gigabyte.', 'contact-forms'); ?>
356 <?php
357 $server_max_size = AccuaForm_Element_File::file_upload_max_size();
358 if ($server_max_size > 0) {
359 esc_html_e( 'This value is limited by server upload limits of ', 'contact-forms');
360 echo esc_html( AccuaForm_Element_File::format_size( $server_max_size ) ) . '. ';
361 esc_html_e( 'If you need a greater limit you should ask to the server administrator.', 'contact-forms');
362 }
363 ?>
364 </small>
365 </div>
366 <?php if (current_user_can('edit_files') || current_user_can('install_plugins')) { ?>
367 <div id="accua_form_dest_path"><?php esc_html_e( 'Upload path', 'contact-forms');?> : <input name="dest_path" class="accua_form_value" type="text" value="<?php echo esc_attr($file_data['dest_path']) ?>" />
368 <small><?php esc_html_e( 'If it stars with \'/\' an absolute path is used, otherwise a path relative to the WordPress installation directory. Default value is "wp-content/uploads/accua-forms"', 'contact-forms');?>.</small>
369 </div>
370 <?php } ?>
371 </div></div>
372
373 <div class="postbox">
374 <div class="postbox-header"><h2><?php esc_html_e( 'reCaptcha settings', 'contact-forms'); ?></h2></div>
375 <div class="inside">
376 <p><?php esc_html_e( 'As reCAPTCHA v1 is discontinued, only reCAPTCHA v2 is supported', 'contact-forms');?></p>
377 <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML with hardcoded link is intentional ?>
378 <p><?php echo strtr(__('Please register this site for reCAPTCHA v2 on %REGISTERURL%, then enter the keys for this site in the following fields', 'contact-forms'), array('%REGISTERURL%' => '<a href="https://www.google.com/recaptcha" target="_blank">google.com/recaptcha</a>'));?></p>
379 <div id="accua_form_recaptcha_public_key"><?php esc_html_e('Site key', 'contact-forms');?> : <input name="recaptcha_public_key" class="accua_form_value" type="text" value="<?php echo esc_attr($captcha_data['recaptcha_public_key']) ?>" />
380 </div>
381 <div id="accua_form_recaptcha_private_key"><?php esc_html_e('Secret key', 'contact-forms');?> : <input name="recaptcha_private_key" class="accua_form_value" type="text" value="<?php echo esc_attr($captcha_data['recaptcha_private_key']) ?>" />
382 </div>
383 </div></div>
384
385 <div class="postbox">
386 <div class="postbox-header"><h2><?php esc_html_e( 'Cloudflare Turnstile settings', 'contact-forms'); ?></h2></div>
387 <div class="inside">
388 <p><?php esc_html_e( 'Cloudflare Turnstile is a modern CAPTCHA alternative that provides bot protection without frustrating user experiences.', 'contact-forms');?></p>
389 <?php
390 $turnstile_plugin_installed = function_exists('cfturnstile_field_show');
391 if (!$turnstile_plugin_installed) {
392 echo '<div class="notice notice-warning inline"><p>';
393 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML with hardcoded link is intentional
394 echo strtr(__('<strong>Required Plugin:</strong> The Turnstile field requires the %PLUGINLINK% plugin to be installed and activated.', 'contact-forms'), array(
395 '%PLUGINLINK%' => '<a href="https://it.wordpress.org/plugins/simple-cloudflare-turnstile/" target="_blank">Simple Cloudflare Turnstile</a>'
396 ));
397 echo '</p></div>';
398 } else {
399 $turnstile_key = get_option('cfturnstile_key', '');
400 $turnstile_secretkey = get_option('cfturnstile_secretkey', '');
401 if (empty($turnstile_key) || empty($turnstile_secretkey)) {
402 echo '<div class="notice notice-info inline"><p>';
403 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML with esc_url() link is intentional
404 echo strtr(__('The plugin is installed. Please configure your Cloudflare Turnstile keys in %SETTINGSLINK%.', 'contact-forms'), array(
405 '%SETTINGSLINK%' => '<a href="' . esc_url( admin_url('options-general.php?page=cfturnstile') ) . '">Settings &rarr; Cloudflare Turnstile</a>'
406 ));
407 echo '</p></div>';
408 } else {
409 echo '<div class="notice notice-success inline"><p>';
410 echo '✓ ' . esc_html__( 'Simple Cloudflare Turnstile plugin is installed and configured.', 'contact-forms' );
411 echo '</p></div>';
412 }
413 }
414 ?>
415 <p><?php esc_html_e( 'Once the Simple Cloudflare Turnstile plugin is installed and configured, you can add the Turnstile field to any form:', 'contact-forms');?></p>
416 <ol style="max-width: 600px;">
417 <li><?php esc_html_e( 'Go to Forms → Edit Form', 'contact-forms');?></li>
418 <li><?php esc_html_e( 'Find "Turnstile" in the Fields sidebar', 'contact-forms');?></li>
419 <li><?php esc_html_e( 'Drag it into your form (typically before the Submit button)', 'contact-forms');?></li>
420 <li><?php esc_html_e( 'Save your form', 'contact-forms');?></li>
421 </ol>
422 <p><?php esc_html_e( 'The Turnstile field gives you complete control over which forms use bot protection - simply add it to the forms that need it.', 'contact-forms');?></p>
423 </div></div>
424
425 <div class="postbox">
426 <div class="postbox-header"><h2><?php esc_html_e( 'Track actions with Google Analytics and/or Matomo', 'contact-forms'); ?></h2></div>
427 <div class="inside">
428 <p>
429 <input type="checkbox" id="accua_form_analytics_track_submit" name="analytics_track_submit" class="accua_form_value" value="1" <?php if($analytics_data['analytics_track_submit']) { echo 'checked="checked"'; } ?> />
430 <label for="accua_form_analytics_track_submit"><?php esc_html_e('Track submissions', 'contact-forms');?></label>
431 </p>
432 <p>
433 <input type="checkbox" id="accua_form_analytics_track_fields" name="analytics_track_fields" class="accua_form_value" value="1" <?php if($analytics_data['analytics_track_fields']) { echo 'checked="checked"'; } ?> />
434 <label for="accua_form_analytics_track_fields"><?php esc_html_e('Track fields filled in', 'contact-forms');?></label>
435 </p>
436 </div></div>
437
438 </div>
439 </div><!-- /panel: integrations -->
440
441 <div class="accua-tabs__panel" role="tabpanel" data-tab="privacy">
442
443 <div class="postbox">
444 <div class="postbox-header"><h2><?php esc_html_e( 'IP address tracking', 'contact-forms'); ?></h2></div>
445 <div class="inside">
446 <p>
447 <?php esc_html_e("Select how many bytes of the visitor's IPs should be masked.", 'contact-forms');?>
448 </p>
449 <p>
450 <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_0" value="0" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 0) { echo 'checked="checked"'; } ?> />
451 <label for="anonymize_ip_bytes_0"><?php esc_html_e('No mask - e.g. 192.168.1.1', 'contact-forms');?></label><br />
452 </p>
453 <p>
454 <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_1" value="1" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 1) { echo 'checked="checked"'; } ?> />
455 <label for="anonymize_ip_bytes_1"><?php esc_html_e('1 byte - e.g. 192.168.1.xxx', 'contact-forms');?></label><br />
456 </p>
457 <p>
458 <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_2" value="2" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 2) { echo 'checked="checked"'; } ?> />
459 <label for="anonymize_ip_bytes_2"><?php esc_html_e('2 byte - e.g. 192.168.xxx.xxx', 'contact-forms');?></label><br />
460 </p>
461 <p>
462 <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_3" value="3" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 3) { echo 'checked="checked"'; } ?> />
463 <label for="anonymize_ip_bytes_3"><?php esc_html_e('3 byte - e.g. 192.xxx.xxx.xxx', 'contact-forms');?></label><br />
464 </p>
465 <p>
466 <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_4" value="4" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 4) { echo 'checked="checked"'; } ?> />
467 <label for="anonymize_ip_bytes_4"><?php esc_html_e('Fully mask IP address', 'contact-forms');?></label><br />
468 </p>
469 <h4><?php esc_html_e( 'Delete IP addresses', 'contact-forms'); ?></h4>
470 <p>
471 <input type="checkbox" id="delete_previous_ip_values" name="delete_previous_ip_values" class="accua_form_value" value="1" />
472 <label for="delete_previous_ip_values"><?php esc_html_e('Delete all previous IP values', 'contact-forms');?></label><br />
473 </p>
474 </div></div>
475
476 <div class="postbox">
477 <div class="postbox-header"><h2><?php esc_html_e( 'Data retention', 'contact-forms'); ?></h2></div>
478 <div class="inside">
479 <p><?php esc_html_e( 'Automatically anonymize or delete form submissions after a specified period. Set to 0 to keep submissions indefinitely.', 'contact-forms'); ?></p>
480 <p>
481 <label for="retention_value"><?php esc_html_e( 'Retention period', 'contact-forms'); ?></label>
482 <input type="number" id="retention_value" name="retention_value" min="0" step="1" value="<?php echo esc_attr( $retention_data['retention_value'] ); ?>" style="width: 80px;" />
483 <select name="retention_unit" id="retention_unit">
484 <option value="days" <?php selected( $retention_data['retention_unit'], 'days' ); ?>><?php esc_html_e( 'days', 'contact-forms'); ?></option>
485 <option value="months" <?php selected( $retention_data['retention_unit'], 'months' ); ?>><?php esc_html_e( 'months', 'contact-forms'); ?></option>
486 <option value="years" <?php selected( $retention_data['retention_unit'], 'years' ); ?>><?php esc_html_e( 'years', 'contact-forms'); ?></option>
487 </select>
488 </p>
489 <p>
490 <strong><?php esc_html_e( 'When submissions expire:', 'contact-forms'); ?></strong><br />
491 <input type="radio" name="retention_mode" id="retention_mode_anonymize" value="anonymize" <?php checked( $retention_data['retention_mode'], 'anonymize' ); ?> />
492 <label for="retention_mode_anonymize"><?php esc_html_e( 'Anonymize — replace personal data with placeholders, keep submission record for statistics', 'contact-forms'); ?></label><br />
493 <input type="radio" name="retention_mode" id="retention_mode_delete" value="delete" <?php checked( $retention_data['retention_mode'], 'delete' ); ?> />
494 <label for="retention_mode_delete"><?php esc_html_e( 'Delete — permanently remove submission records from the database', 'contact-forms'); ?></label>
495 </p>
496 <p class="description"><?php esc_html_e( 'Individual forms can override this setting in the form editor.', 'contact-forms'); ?></p>
497 <p class="description"><?php
498 /* translators: %s: URL to the WordPress Erase Personal Data tool */
499 printf( esc_html__( 'To manually erase data for a specific person, use the WordPress %s tool.', 'contact-forms'),
500 '<a href="' . esc_url( admin_url( 'erase-personal-data.php' ) ) . '">' . esc_html__( 'Erase Personal Data', 'contact-forms') . '</a>'
501 );
502 ?></p>
503 </div></div>
504
505 </div><!-- /panel: privacy -->
506
507 <div class="accua-tabs__panel" role="tabpanel" data-tab="styling">
508 <div class="accua-settings-grid">
509
510 <div class="postbox">
511 <div class="postbox-header"><h2><?php esc_html_e( 'Form Container', 'contact-forms'); ?></h2></div>
512 <div class="inside">
513 <table class="form-table" role="presentation">
514 <tr>
515 <th scope="row"><label for="accua_form_layout_select"><?php esc_html_e( 'Layout', 'contact-forms'); ?></label></th>
516 <td>
517 <select id="accua_form_layout_select" name="layout" class="accua_form_value">
518 <option value="sidebyside" <?php selected( 'sidebyside', $form_data['layout'] ); ?>><?php echo esc_html( accua_forms_get_layout_label( 'sidebyside' ) ); ?></option>
519 <option value="toplabel" <?php selected( 'toplabel', $form_data['layout'] ); ?>><?php echo esc_html( accua_forms_get_layout_label( 'toplabel' ) ); ?></option>
520 <option value="inlinelabel" <?php selected( 'inlinelabel', $form_data['layout'] ); ?>><?php echo esc_html( accua_forms_get_layout_label( 'inlinelabel' ) ); ?></option>
521 </select>
522 <p class="description"><?php esc_html_e( 'With "Labels on the left", labels move above the fields automatically when the form container is narrower than 500px.', 'contact-forms' ); ?></p>
523 </td>
524 </tr>
525 <tr>
526 <th scope="row"><label for="accua_style_margin"><?php esc_html_e( 'Margin', 'contact-forms'); ?></label></th>
527 <td><input id="accua_style_margin" name="style_margin" class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['style_margin']) ?>" /></td>
528 </tr>
529 <tr>
530 <th scope="row"><label for="accua_style_border_color"><?php esc_html_e( 'Border color', 'contact-forms'); ?></label></th>
531 <td><input id="accua_style_border_color" name="style_border_color" class="accua_form_value accua-color-picker" type="text" value="<?php echo esc_attr($form_data['style_border_color']) ?>" /></td>
532 </tr>
533 <tr>
534 <th scope="row"><label for="accua_style_border_width"><?php esc_html_e( 'Border width', 'contact-forms'); ?></label></th>
535 <td><input id="accua_style_border_width" name="style_border_width" class="accua_form_value small-text" type="text" value="<?php echo esc_attr($form_data['style_border_width']) ?>" /></td>
536 </tr>
537 <tr>
538 <th scope="row"><label for="accua_style_border_radius"><?php esc_html_e( 'Rounded corner radius', 'contact-forms'); ?></label></th>
539 <td><input id="accua_style_border_radius" name="style_border_radius" class="accua_form_value small-text" type="text" value="<?php echo esc_attr($form_data['style_border_radius']) ?>" /></td>
540 </tr>
541 <tr>
542 <th scope="row"><label for="accua_style_background_color"><?php esc_html_e( 'Background color', 'contact-forms'); ?></label></th>
543 <td><input id="accua_style_background_color" name="style_background_color" class="accua_form_value accua-color-picker" type="text" value="<?php echo esc_attr($form_data['style_background_color']) ?>" /></td>
544 </tr>
545 <tr>
546 <th scope="row"><label for="accua_style_padding"><?php esc_html_e( 'Padding', 'contact-forms'); ?></label></th>
547 <td><input id="accua_style_padding" name="style_padding" class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['style_padding']) ?>" /></td>
548 </tr>
549 <tr>
550 <th scope="row"><label for="accua_style_color"><?php esc_html_e( 'Text color', 'contact-forms'); ?></label></th>
551 <td><input id="accua_style_color" name="style_color" class="accua_form_value accua-color-picker" type="text" value="<?php echo esc_attr($form_data['style_color']) ?>" /></td>
552 </tr>
553 <tr>
554 <th scope="row"><label for="accua_style_font_size"><?php esc_html_e( 'Font size', 'contact-forms'); ?></label></th>
555 <td><input id="accua_style_font_size" name="style_font_size" class="accua_form_value small-text" type="text" value="<?php echo esc_attr($form_data['style_font_size']) ?>" /></td>
556 </tr>
557 </table>
558 </div></div>
559
560 <div class="postbox">
561 <div class="postbox-header"><h2><?php esc_html_e( 'Fields', 'contact-forms'); ?></h2></div>
562 <div class="inside">
563 <table class="form-table" role="presentation">
564 <tr>
565 <th scope="row"><label for="accua_style_field_spacing"><?php esc_html_e( 'Spacing', 'contact-forms'); ?></label></th>
566 <td><input id="accua_style_field_spacing" name="style_field_spacing" class="accua_form_value small-text" type="text" value="<?php echo esc_attr($form_data['style_field_spacing']) ?>" /></td>
567 </tr>
568 <tr>
569 <th scope="row"><label for="accua_style_field_border_color"><?php esc_html_e( 'Border color', 'contact-forms'); ?></label></th>
570 <td><input id="accua_style_field_border_color" name="style_field_border_color" class="accua_form_value accua-color-picker" type="text" value="<?php echo esc_attr($form_data['style_field_border_color']) ?>" /></td>
571 </tr>
572 <tr>
573 <th scope="row"><label for="accua_style_field_border_width"><?php esc_html_e( 'Border width', 'contact-forms'); ?></label></th>
574 <td><input id="accua_style_field_border_width" name="style_field_border_width" class="accua_form_value small-text" type="text" value="<?php echo esc_attr($form_data['style_field_border_width']) ?>" /></td>
575 </tr>
576 <tr>
577 <th scope="row"><label for="accua_style_field_border_radius"><?php esc_html_e( 'Rounded corner radius', 'contact-forms'); ?></label></th>
578 <td><input id="accua_style_field_border_radius" name="style_field_border_radius" class="accua_form_value small-text" type="text" value="<?php echo esc_attr($form_data['style_field_border_radius']) ?>" /></td>
579 </tr>
580 <tr>
581 <th scope="row"><label for="accua_style_field_background_color"><?php esc_html_e( 'Background color', 'contact-forms'); ?></label></th>
582 <td><input id="accua_style_field_background_color" name="style_field_background_color" class="accua_form_value accua-color-picker" type="text" value="<?php echo esc_attr($form_data['style_field_background_color']) ?>" /></td>
583 </tr>
584 <tr>
585 <th scope="row"><label for="accua_style_field_padding"><?php esc_html_e( 'Padding', 'contact-forms'); ?></label></th>
586 <td><input id="accua_style_field_padding" name="style_field_padding" class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['style_field_padding']) ?>" /></td>
587 </tr>
588 <tr>
589 <th scope="row"><label for="accua_style_field_color"><?php esc_html_e( 'Text color', 'contact-forms'); ?></label></th>
590 <td><input id="accua_style_field_color" name="style_field_color" class="accua_form_value accua-color-picker" type="text" value="<?php echo esc_attr($form_data['style_field_color']) ?>" /></td>
591 </tr>
592 </table>
593 </div></div>
594
595 <div class="postbox">
596 <div class="postbox-header"><h2><?php esc_html_e( 'Submit Button', 'contact-forms'); ?></h2></div>
597 <div class="inside">
598 <table class="form-table" role="presentation">
599 <tr>
600 <th scope="row"><label for="accua_style_submit_border_color"><?php esc_html_e( 'Border color', 'contact-forms'); ?></label></th>
601 <td><input id="accua_style_submit_border_color" name="style_submit_border_color" class="accua_form_value accua-color-picker" type="text" value="<?php echo esc_attr($form_data['style_submit_border_color']) ?>" /></td>
602 </tr>
603 <tr>
604 <th scope="row"><label for="accua_style_submit_border_width"><?php esc_html_e( 'Border width', 'contact-forms'); ?></label></th>
605 <td><input id="accua_style_submit_border_width" name="style_submit_border_width" class="accua_form_value small-text" type="text" value="<?php echo esc_attr($form_data['style_submit_border_width']) ?>" /></td>
606 </tr>
607 <tr>
608 <th scope="row"><label for="accua_style_submit_border_radius"><?php esc_html_e( 'Rounded corner radius', 'contact-forms'); ?></label></th>
609 <td><input id="accua_style_submit_border_radius" name="style_submit_border_radius" class="accua_form_value small-text" type="text" value="<?php echo esc_attr($form_data['style_submit_border_radius']) ?>" /></td>
610 </tr>
611 <tr>
612 <th scope="row"><label for="accua_style_submit_background_color"><?php esc_html_e( 'Background color', 'contact-forms'); ?></label></th>
613 <td><input id="accua_style_submit_background_color" name="style_submit_background_color" class="accua_form_value accua-color-picker" type="text" value="<?php echo esc_attr($form_data['style_submit_background_color']) ?>" /></td>
614 </tr>
615 <tr>
616 <th scope="row"><label for="accua_style_submit_padding"><?php esc_html_e( 'Padding', 'contact-forms'); ?></label></th>
617 <td><input id="accua_style_submit_padding" name="style_submit_padding" class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['style_submit_padding']) ?>" /></td>
618 </tr>
619 <tr>
620 <th scope="row"><label for="accua_style_submit_color"><?php esc_html_e( 'Text color', 'contact-forms'); ?></label></th>
621 <td><input id="accua_style_submit_color" name="style_submit_color" class="accua_form_value accua-color-picker" type="text" value="<?php echo esc_attr($form_data['style_submit_color']) ?>" /></td>
622 </tr>
623 <tr>
624 <th scope="row"><label for="accua_style_submit_font_size"><?php esc_html_e( 'Font size', 'contact-forms'); ?></label></th>
625 <td><input id="accua_style_submit_font_size" name="style_submit_font_size" class="accua_form_value small-text" type="text" value="<?php echo esc_attr($form_data['style_submit_font_size']) ?>" /></td>
626 </tr>
627 </table>
628 </div></div>
629
630 </div>
631 </div><!-- /panel: styling -->
632
633 <?php if ( current_user_can( 'manage_options' ) ) : ?>
634 <div class="accua-tabs__panel" role="tabpanel" data-tab="danger_zone">
635
636 <div class="postbox accua-danger-zone">
637 <div class="postbox-header"><h2><?php esc_html_e( 'Anonymize old submissions', 'contact-forms' ); ?></h2></div>
638 <div class="inside">
639 <p class="description"><?php esc_html_e( 'Anonymize all submissions older than the specified period, across all forms. This replaces personal data with placeholders and sets IP to 0.0.0.0. This cannot be undone.', 'contact-forms' ); ?></p>
640 <p>
641 <input type="number" id="accua_danger_anon_value" min="1" step="1" value="12" style="width: 80px;" />
642 <select id="accua_danger_anon_unit" style="vertical-align: baseline;">
643 <option value="days"><?php esc_html_e( 'days', 'contact-forms' ); ?></option>
644 <option value="months" selected><?php esc_html_e( 'months', 'contact-forms' ); ?></option>
645 <option value="years"><?php esc_html_e( 'years', 'contact-forms' ); ?></option>
646 </select>
647 <button type="button" id="accua_danger_anon_btn" class="button" style="color: #d63638; border-color: #d63638;"><?php esc_html_e( 'Anonymize submissions', 'contact-forms' ); ?></button>
648 </p>
649 <div id="accua_danger_anon_result" style="display:none;"></div>
650 </div></div>
651
652 <div class="postbox accua-danger-zone">
653 <div class="postbox-header"><h2><?php esc_html_e( 'Delete all Contact Forms data', 'contact-forms' ); ?></h2></div>
654 <div class="inside">
655 <p class="description"><?php esc_html_e( 'Permanently delete ALL Contact Forms settings, forms, submissions, and uploaded files. The plugin will remain installed but completely reset. Make a full backup before proceeding.', 'contact-forms' ); ?></p>
656 <p>
657 <button type="button" id="accua_danger_delete_btn" class="button" style="color: #d63638; border-color: #d63638;"><?php esc_html_e( 'Delete all data', 'contact-forms' ); ?></button>
658 </p>
659 <div id="accua_danger_delete_result" style="display:none;"></div>
660 </div></div>
661
662 </div><!-- /panel: danger_zone -->
663 <?php endif; ?>
664
665 <div class="accua-tabs__panel" role="tabpanel" data-tab="tokens">
666 <?php accua_forms_print_tokens(); ?>
667 </div><!-- /panel: tokens -->
668
669 <div class="accua-tabs__panel" role="tabpanel" data-tab="theme_helper">
670 <?php accua_forms_theme_helper_content(); ?>
671 </div><!-- /panel: theme_helper -->
672
673 </div><!-- /accua_settings_tabs -->
674
675 <?php /*
676 <h3><?php _e( 'File upload default settings', 'contact-forms'); ?></h3>
677 <p id="accua_form_valid_extensions"><?php _e( 'Valid extensions', 'contact-forms'); ?> <br /><textarea name="valid_extensions" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($file_data['valid_extensions'], ENT_QUOTES) ?></textarea>
678 <small><?php _e( 'List of valid extensions, without dot, one per line.', 'contact-forms'); ?></small>
679 </p>
680 <p id="accua_form_max_size"><?php _e( 'Maximum file size:', 'contact-forms'); ?> <input name="max_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['max_size'], ENT_QUOTES) ?>" /><br />
681 <small><?php _e( 'You can use suffix K, M or G for kilobyte, megabyte or gigabyte.', 'contact-forms'); ?>
682 <?php
683 $server_max_size = AccuaForm_Element_File::file_upload_max_size();
684 if ($server_max_size > 0) {
685 _e( 'This value is limited by server upload limits of ', 'contact-forms');
686 echo AccuaForm_Element_File::format_size($server_max_size).". ";
687 _e( 'If you need a greater limit you should ask to the server administrator.', 'contact-forms');
688 }
689 ?>
690 </small></p>
691 <p id="accua_form_dest_path"><?php _e( 'Upload path', 'contact-forms');?> : <input name="dest_path" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['dest_path'], ENT_QUOTES) ?>" />
692 <small><?php _e( 'If it stars with \'/\' an absolute path is used, otherwise a path relative to the WordPress installation directory. Default value is "wp-content/uploads/accua-forms"', 'contact-forms');?>.</small>
693 </p> */ ?>
694 <p><input class="button button-primary button-large" id="accua_form_save_settings" type="submit" value="Save settings" /></p>
695
696 </form>
697
698 <span id="accua-forms-version"><?php
699 $plugin_data = get_plugin_data( ACCUA_FORMS_FILE );
700 echo esc_html( $plugin_data['Name'] ); ?> &mdash; <a href="https://www.cimatti.it/en/wordpress-plugins/contact-forms/"><?php
701 esc_html_e('Version', 'contact-forms'); echo ' ' . esc_html( $plugin_data['Version'] ); ?></a></span>
702
703 </div>
704
705 <?php
706 }
707