PluginProbe
Contact Forms by Cimatti / 1.9.2
Contact Forms by Cimatti v1.9.2
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
← All changes | accua-forms.php +1129 -3620 2.2.41.9.2 View file →
@@ -1,13 +1,11 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) exit;
3 -
4 2 add_action('admin_menu', 'accua_forms_menu', -95);
5 3 function accua_forms_menu(){
6 - $dashboard_admin_page=add_menu_page('Contact Forms by Cimatti', 'Contact Forms', 'manage_options', 'accua_forms', 'accua_forms_dashboard_page', 'data:image/svg+xml;base64,' . base64_encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44.46 44.46"><path fill="#15caff" d="m23.97,28.72c1.85,0,2.93-.11,2.93-.11,1.49-.15,2.75.95,2.8,2.44l.01.14c.05,1.5-1.11,2.96-2.58,3.25,0,0-2.53.5-5.25.5-7.24,0-10.11-3.84-10.11-12.98,0-8.6,3.01-12.44,10.26-12.44,2.82,0,5.11.47,5.11.47,1.47.3,2.63,1.78,2.57,3.27l-.01.15c-.05,1.5-1.31,2.6-2.8,2.45,0,0-1.13-.12-2.98-.12-4.67,0-5.54,1.6-5.54,6.22,0,5.2.92,6.76,5.59,6.76M33.36,1.93c-1.06-1.06-3.15-1.93-4.65-1.93H15.75c-1.5,0-3.59.87-4.65,1.93L1.93,11.1C.87,12.16,0,14.25,0,15.75v12.97c0,1.5.87,3.59,1.93,4.65l9.17,9.17c1.06,1.06,3.15,1.93,4.65,1.93h12.97c1.5,0,3.59-.87,4.65-1.93l9.17-9.17c1.06-1.06,1.93-3.15,1.93-4.65V15.75c0-1.5-.87-3.59-1.93-4.65z"/></svg>'), '90.90300');
4 + $dashboard_admin_page=add_menu_page('Wordpress Contact Forms by Cimatti', 'Contact Forms', 'manage_options', 'accua_forms', 'accua_forms_dashboard_page', ACCUA_FORMS_DIR_URL.'img/cimatti-icon-10.png', '90.90300');
7 5 add_action('load-'.$dashboard_admin_page, 'accua_forms_dashboard_page_head');
8 6
9 - add_submenu_page('accua_forms', 'Contact Forms by Cimatti', 'Dashboard', 'manage_options', "accua_forms", 'accua_forms_dashboard_page');
7 + add_submenu_page('accua_forms', 'Wordpress Contact Forms by Cimatti', 'Dashboard', 'manage_options', "accua_forms", 'accua_forms_dashboard_page');
10 8
11 9 $form_edit_page = add_submenu_page('accua_forms', 'Forms', 'Forms', 'manage_options', "accua_forms_list", 'accua_forms_list_page');
12 10 add_action('admin_head-'.$form_edit_page, 'accua_forms_edit_page_head');
13 11 add_action( 'admin_print_styles-'.$form_edit_page, 'accua_forms_edit_page_head_styles');
@@ -18,9 +16,8 @@
18 16 add_action( 'admin_print_styles-'.$form_add_page, 'accua_forms_edit_page_head_styles');
19 17 add_action( 'admin_print_scripts-'.$form_add_page, 'accua_forms_edit_page_head_scripts');
20 18
21 19 $form_submissions_page = add_submenu_page('accua_forms', __('Forms submissions', 'contact-forms') , __('Submissions', 'contact-forms'), 'manage_options', "accua_forms_submissions_list", '__accua_forms_submissions_list_page');
22 - add_action('load-'.$form_submissions_page, 'accua_forms_submissions_list_page_load');
23 20 add_action('admin_head-'.$form_submissions_page, 'accua_forms_submissions_list_page_head');
24 21 add_action( 'admin_print_styles-'.$form_submissions_page, 'accua_forms_edit_page_head_styles');
25 22
26 23 $form_fields_page = add_submenu_page('accua_forms', __( 'Form fields', 'contact-forms'), __('Fields', 'contact-forms'), 'manage_options', "accua_forms_fields", 'accua_forms_fields_page');
@@ -33,8 +30,9 @@
33 30
34 31 wp_enqueue_script('jquery-form');
35 32 wp_enqueue_script('jquery-color');
36 33 wp_enqueue_script('jquery-ui-core');
34 + wp_enqueue_script('jquery-ui-tabs');
37 35 wp_enqueue_script('jquery-ui-sortable');
38 36 wp_enqueue_script('jquery-ui-draggable');
39 37 wp_enqueue_script('jquery-ui-droppable');
40 38 wp_enqueue_script('jquery-ui-selectable');
@@ -73,9 +71,8 @@
73 71 FROM `{$wpdb->prefix}cformssubmissions`
74 72 GROUP BY `year`, `month`
75 73 ORDER BY `year` DESC, `month` DESC";
76 74
77 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared -- No user input in query
78 75 $results = $wpdb->get_results($query);
79 76
80 77 if ($results) {
81 78 ?>
@@ -102,24 +99,13 @@
102 99 array( 'label' => __( 'Unique submissions', 'contact-forms'), 'data' => array()),
103 100 array( 'label' => __( 'Total submissions', 'contact-forms'), 'data' => array()),
104 101 );
105 102 foreach ($results as $result){
106 - $month = esc_html( $months[$result->month] );
107 - $year = esc_html( $result->year );
108 - $unique_submissions = esc_html( $result->unique_submissions );
109 - $submissions = esc_html( $result->submissions );
110 - $alternate_class = ( $alternate = ! $alternate ) ? 'alternate' : '';
111 - $month_style = in_array( 'month', $hidden, true ) ? " style='display:none;'" : '';
112 - $unique_style = in_array( 'unique_submissions', $hidden, true ) ? " style='display:none;'" : '';
113 - $sub_style = in_array( 'submissions', $hidden, true ) ? " style='display:none;'" : '';
114 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- All variables pre-escaped above
115 - echo "<tr class='iedit " . esc_attr( $alternate_class ) . "'>\n";
116 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $month, $year pre-escaped with esc_html()
117 - echo "<td class='column-month'" . $month_style . ">" . $month . " " . $year . "</td>\n";
118 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $unique_submissions pre-escaped with esc_html()
119 - echo "<td class='column-unique_submissions'" . $unique_style . ">" . $unique_submissions . "</td>\n";
120 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $submissions pre-escaped with esc_html()
121 - echo "<td class='column-submissions'" . $sub_style . ">" . $submissions . "</td>\n";
103 + $month = $months[$result->month];
104 + echo "<tr class='iedit ".(($alternate = !$alternate)?'alternate':'')."'>\n";
105 + echo "<td class='column-month'".(in_array('month', $hidden)?" style='display:none;'":'').">$month {$result->year}</td>\n";
106 + echo "<td class='column-unique_submissions'".(in_array('unique_submissions', $hidden)?" style='display:none;'":'').">{$result->unique_submissions}</td>\n";
107 + echo "<td class='column-submissions'".(in_array('submissions', $hidden)?" style='display:none;'":'').">{$result->submissions}</td>\n";
122 108 echo "</tr>\n";
123 109 $time = mktime(0, 0, 0, $result->month, 1, $result->year) * 1000;
124 110 $data[0]['data'][] = array($time, (int)$result->unique_submissions);
125 111 $data[1]['data'][] = array($time, (int)$result->submissions);
@@ -140,9 +126,8 @@
140 126 </tbody>
141 127 </table>
142 128 <script type="text/javascript">
143 129 jQuery(function($){
144 - <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- JSON encoded data for JavaScript ?>
145 130 var data = <?php print _accua_forms_json_encode($data); ?> ;
146 131 var options = {
147 132 xaxis: {
148 133 //autoscaleMargin: 0.005,
@@ -167,9 +152,9 @@
167 152
168 153 function accua_forms_edit_page_head_styles() {
169 154 //wp_admin_css( 'widgets' );
170 155 wp_enqueue_style( 'wp-pointer' ); //for tooltips
171 - wp_enqueue_style( 'accua-forms-admin', plugins_url('assets/css/admin.css', ACCUA_FORMS_FILE), array(), ACCUA_FORMS_CSS_VERSION); //
156 + wp_enqueue_style( 'accua-forms-admin', plugins_url('accua-forms-admin.css', ACCUA_FORMS_FILE), array(), ACCUA_FORMS_CSS_VERSION); //
172 157 }
173 158
174 159 function accua_forms_edit_page_head_scripts() {
175 160 //wp_enqueue_script('admin-widgets');
@@ -175,129 +160,20 @@
175 160 //wp_enqueue_script('admin-widgets');
176 161 /*wp_enqueue_script('jquery-ui-sortable');
177 162 wp_enqueue_script('jquery-ui-draggable');
178 163 wp_enqueue_script('jquery-ui-droppable');*/
179 - wp_enqueue_script( 'wp-pointer', '', array(), ACCUA_FORMS_JS_VERSION, true ); // for tooltips
180 - wp_enqueue_style('wp-color-picker');
181 - wp_enqueue_script('wp-color-picker', '', array(), ACCUA_FORMS_JS_VERSION, true );
164 + wp_enqueue_script( 'wp-pointer' ); //for tooltips
165 + wp_enqueue_script('accua-jqColorPicker', plugins_url('/js/jqColorPicker.min.js', ACCUA_FORMS_FILE ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION);
182 166
183 - wp_enqueue_script( 'accua-form-fields', plugins_url( 'assets/js/admin/form-fields.js' , ACCUA_FORMS_FILE ), array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), ACCUA_FORMS_JS_VERSION, true );
184 - wp_enqueue_script( 'accua-form-settings', plugins_url('assets/js/admin/form-settings.js', ACCUA_FORMS_FILE), array('jquery', 'wp-color-picker'), ACCUA_FORMS_JS_VERSION, true );
167 + wp_enqueue_script( 'accua-form-fields', plugins_url( 'form-fields.js' , ACCUA_FORMS_FILE ), array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), ACCUA_FORMS_JS_VERSION);
168 + wp_enqueue_script( 'accua-form-settings', plugins_url('form-settings.js', ACCUA_FORMS_FILE), array('jquery'), ACCUA_FORMS_JS_VERSION);
185 169 }
186 170
187 171 function accua_forms_settings_page_head_scripts() {
188 - wp_enqueue_style('wp-color-picker');
189 - wp_enqueue_script('wp-color-picker');
190 -
191 - // Enqueue settings page JavaScript
192 - wp_enqueue_script('accua_tabs_component', plugins_url('assets/js/admin/accua-tabs.js', ACCUA_FORMS_FILE), array('jquery'), ACCUA_FORMS_JS_VERSION, true);
193 - wp_enqueue_script('accua-forms-settings-page', plugins_url('assets/js/admin/settings-page.js', ACCUA_FORMS_FILE), array('jquery', 'accua_tabs_component'), ACCUA_FORMS_JS_VERSION, true);
194 -
195 - // Theme Helper tab scripts
196 - wp_enqueue_script(
197 - 'accua-forms-theme-helper',
198 - plugins_url('assets/js/admin/theme-helper.js', ACCUA_FORMS_FILE),
199 - array('jquery'),
200 - ACCUA_FORMS_JS_VERSION,
201 - true
202 - );
203 - wp_localize_script('accua-forms-theme-helper', 'accuaThemeHelper', array(
204 - 'ajaxUrl' => admin_url('admin-ajax.php'),
205 - 'nonce' => wp_create_nonce('accua_theme_helper'),
206 - 'pluginCssUrl' => plugins_url('assets/css/frontend.css', ACCUA_FORMS_FILE),
207 - 'i18n' => array(
208 - 'scanning' => __('Scanning...', 'contact-forms'),
209 - 'noConflicts' => __('No CSS conflicts detected!', 'contact-forms'),
210 - 'conflictsFound' => __('CSS conflicts found:', 'contact-forms'),
211 - 'scanComplete' => __('Scan complete', 'contact-forms'),
212 - 'scanError' => __('Error scanning URL', 'contact-forms'),
213 - 'enterUrl' => __('Enter a URL to scan', 'contact-forms'),
214 - 'fetchingCss' => __('Fetching CSS from URL...', 'contact-forms'),
215 - ),
216 - 'monitoredClasses' => accua_forms_get_monitored_css_classes(),
217 - 'criticalProperties' => array(
218 - 'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
219 - 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
220 - 'display', 'position', 'visibility', 'overflow',
221 - 'width', 'height', 'min-width', 'min-height', 'max-width', 'max-height',
222 - 'flex', 'flex-direction', 'flex-wrap', 'align-items', 'justify-content',
223 - 'border', 'border-width', 'border-style',
224 - 'float', 'clear', 'z-index', 'opacity',
225 - ),
226 - ));
227 -
228 - // Localize script with AJAX URL, nonce, and translations
229 - wp_localize_script('accua-forms-settings-page', 'accuaFormsSettings', array(
230 - 'ajaxUrl' => admin_url('admin-ajax.php'),
231 - 'nonce' => wp_create_nonce('accua_forms_restore_default'),
232 - 'dangerNonce' => wp_create_nonce('accua_forms_danger_zone'),
233 - 'siteDomain' => wp_parse_url( home_url(), PHP_URL_HOST ),
234 - 'i18n' => array(
235 - 'confirmRestore' => __('Are you sure you want to restore the default value for this message? This will overwrite your current content.', 'contact-forms'),
236 - 'restoring' => __('Restoring...', 'contact-forms'),
237 - 'restored' => __('Restored!', 'contact-forms'),
238 - 'error' => __('Error restoring default', 'contact-forms'),
239 - 'restoreDefault' => __('Restore default', 'contact-forms'),
240 - 'anonymizing' => __('Anonymizing...', 'contact-forms'),
241 - 'loading' => __('Loading...', 'contact-forms'),
242 - 'deleting' => __('Deleting...', 'contact-forms'),
243 - 'noSubmissionsFound' => __('No submissions found matching the specified period.', 'contact-forms'),
244 - /* translators: %d: total number of submissions that will be anonymized */
245 - 'previewHeading' => __('The following %d submissions will be anonymized:', 'contact-forms'),
246 - 'formColumn' => __('Form', 'contact-forms'),
247 - 'submissionsColumn' => __('Submissions', 'contact-forms'),
248 - 'totalLabel' => __('Total', 'contact-forms'),
249 - 'confirmAnonymize' => __('Confirm anonymization', 'contact-forms'),
250 - 'cancel' => __('Cancel', 'contact-forms'),
251 - 'confirmDeletePrompt' => sprintf(
252 - /* translators: %s: site domain */
253 - __( 'This will permanently delete ALL Contact Forms data (settings, forms, submissions, uploaded files). This cannot be undone. Type "%s" to confirm:', 'contact-forms' ),
254 - wp_parse_url( home_url(), PHP_URL_HOST )
255 - ),
256 - ),
257 - ));
172 + wp_enqueue_script('accua-jqColorPicker', plugins_url('/js/jqColorPicker.min.js', ACCUA_FORMS_FILE ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION);
258 173 }
259 174
260 -/**
261 - * Enqueue deactivation modal script on the Plugins page.
262 - */
263 -add_action( 'admin_enqueue_scripts', 'accua_forms_enqueue_deactivation_modal' );
264 -function accua_forms_enqueue_deactivation_modal( $hook ) {
265 - if ( $hook !== 'plugins.php' ) {
266 - return;
267 - }
268 -
269 - wp_enqueue_script(
270 - 'accua-forms-deactivation-modal',
271 - plugins_url( 'assets/js/admin/deactivation-modal.js', ACCUA_FORMS_FILE ),
272 - array( 'jquery' ),
273 - ACCUA_FORMS_JS_VERSION,
274 - true
275 - );
276 -
277 - wp_localize_script( 'accua-forms-deactivation-modal', 'accuaFormsDeactivation', array(
278 - 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
279 - 'nonce' => wp_create_nonce( 'accua_forms_deactivation_cleanup' ),
280 - 'pluginBasename' => plugin_basename( ACCUA_FORMS_FILE ),
281 - 'i18n' => array(
282 - 'title' => __( 'What would you like to do with your Contact Forms data?', 'contact-forms' ),
283 - 'description' => __( 'You are about to deactivate Contact Forms. Choose what to do with your existing data:', 'contact-forms' ),
284 - 'deleteAll' => __( 'Delete all data', 'contact-forms' ),
285 - 'deleteAllDesc' => __( 'Permanently remove all forms, submissions, settings, and uploaded files. This cannot be undone.', 'contact-forms' ),
286 - 'anonymizeAll' => __( 'Anonymize all submissions', 'contact-forms' ),
287 - 'anonymizeAllDesc'=> __( 'Replace personal data with placeholders and set IPs to 0.0.0.0. Forms and settings will be kept. This cannot be undone.', 'contact-forms' ),
288 - 'skip' => __( 'Just deactivate', 'contact-forms' ),
289 - 'skipDesc' => __( 'Keep all data. You can reactivate the plugin later.', 'contact-forms' ),
290 - 'confirmDelete' => __( 'Are you sure? This will permanently delete ALL forms, submissions, settings, and uploaded files. This cannot be undone.', 'contact-forms' ),
291 - 'confirmAnonymize'=> __( 'Are you sure? This will anonymize ALL submissions, replacing personal data with placeholders. This cannot be undone.', 'contact-forms' ),
292 - 'processing' => __( 'Processing…', 'contact-forms' ),
293 - 'cancel' => __( 'Cancel', 'contact-forms' ),
294 - ),
295 - ) );
296 -}
297 -
298 175 function accua_forms_edit_page_head() {
299 -// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended -- Detection only, actual action processing in _accua_forms_form_edit_action() has nonce check
300 176 if (isset($_POST['accua-form-edit-action']) || (!isset($_GET['fid']))) {
301 177 _accua_forms_form_edit_action();
302 178 require_once('accua-forms-list-page.php');
303 179 accua_forms_list_page_table(true);
@@ -332,24 +208,22 @@
332 208 if (empty($post['sidebars'])) {
333 209 die('-1');
334 210 }
335 211
336 - // Save to draft instead of directly to database
337 - foreach ($post['sidebars'] as $sidebar_id => $order) {
338 - if (strpos($sidebar_id, 'cimatti-accua-fields-form-area-') !== 0){
212 + $forms_data = get_option('accua_forms_saved_forms', array());
213 +
214 + foreach ($post['sidebars'] as $fid => $order) {
215 + if (strpos($fid, 'cimatti-accua-fields-form-area-') !== 0){
339 216 die('-1');
340 217 }
341 - $fid = substr($sidebar_id, 31);
218 + $fid = substr($fid, 31);
342 219
343 - // Get draft data for this form
344 - $draft_data = _accua_forms_get_draft_data($fid);
345 -
346 - if (empty($draft_data['fields'])) {
220 + if (empty($forms_data[$fid]['fields'])) {
347 221 die('-1');
348 222 }
349 223
350 - $old_fields = $draft_data['fields'];
351 - unset($draft_data['fields']);
224 + $old_fields = $forms_data[$fid]['fields'];
225 + unset($forms_data[$fid]['fields']);
352 226 $new_fields = array();
353 227
354 228 $order = explode(',', $order);
355 229
@@ -363,19 +237,18 @@
363 237
364 238 if($old_fields){
365 239 $new_fields += $old_fields;
366 240 }
367 - $draft_data['fields'] = $new_fields;
241 + $forms_data[$fid]['fields'] = $new_fields;
242 + }
368 243
369 - // Save to draft (not to live database)
370 - _accua_forms_save_draft($fid, $draft_data);
371 - }
244 + update_option('accua_forms_saved_forms', $forms_data);
372 245
373 246 die('1');
374 247 }
375 248
376 249 add_action( 'wp_ajax_accua-save-form-field', 'accua_forms_save_form_field');
377 -/* azione dove vengono salvati i campi dei un form - saves to draft */
250 +/* azione dove vengono salvati i campi dei un form */
378 251 function accua_forms_save_form_field() {
379 252 if (!current_user_can('manage_options')){
380 253 wp_die( -1, 403 );
381 254 }
@@ -384,17 +257,15 @@
384 257 $post = stripslashes_deep($_POST);
385 258
386 259 //update_option('accua_forms_save_form_field_post', $post);
387 260
261 + $forms_data = get_option('accua_forms_saved_forms', array());
388 262 $fid = $post['form-id'];
389 263 if (accua_forms_validate_form_id($fid) !== '') {
390 264 die('-1');
391 265 }
392 -
393 - // Get draft data instead of live data
394 - $draft_data = _accua_forms_get_draft_data($fid);
395 - if (empty($draft_data['fields'])) {
396 - $draft_data['fields'] = array();
266 + if (empty($forms_data[$fid]['fields'])) {
267 + $forms_data[$fid]['fields'] = array();
397 268 }
398 269
399 270 $avail_fields = get_option('accua_forms_avail_fields', array());
400 271 @ $wid = (string) $post['widget-id'];
@@ -415,15 +286,15 @@
415 286 }
416 287 $required = !empty($post["form-field-{$wid}-required"]);
417 288 $widget_number = empty($post['multi_number']) ? (empty($post['widget_number']) ? '' : (int)$post['widget_number']) : (int)$post['multi_number'];
418 289
419 - if (isset($draft_data['fields'][$wid])) {
420 - $old_istance_data = $draft_data['fields'][$wid];
290 + if (isset($forms_data[$fid]['fields'][$wid])) {
291 + $old_istance_data = $forms_data[$fid]['fields'][$wid];
421 292 } else {
422 293 $old_istance_data = array();
423 294 }
424 295
425 - $draft_data['fields'][$wid] = array (
296 + $forms_data[$fid]['fields'][$wid] = array (
426 297 'version' => 2,
427 298 'istance_id' => $wid,
428 299 'widget_number' => $widget_number,
429 300 'ref' => $ref,
@@ -434,9 +305,9 @@
434 305 @ $label = (string) $post["form-field-{$wid}-label"];
435 306 if (!current_user_can('unfiltered_html')) {
436 307 $label = wp_kses($label, 'post');
437 308 }
438 - $draft_data['fields'][$wid]['label'] = $label;
309 + $forms_data[$fid]['fields'][$wid]['label'] = $label;
439 310 }
440 311
441 312 $is_file = false;
442 313 $is_date = false;
@@ -442,9 +313,9 @@
442 313 $is_date = false;
443 314 if (isset($avail_fields[$wid]['type'])) {
444 315 if ($avail_fields[$wid]['type'] == 'file') {
445 316 $is_file = true;
446 - } elseif ($avail_fields[$wid]['type'] == 'date') {
317 + } else if ($avail_fields[$wid]['type'] == 'date') {
447 318 $is_date = true;
448 319 }
449 320 }
450 321
@@ -451,101 +322,36 @@
451 322 if (!empty($post["form-field-{$wid}-override-default-value"])) {
452 323 @ $default_value = (string) $post["form-field-{$wid}-default-value"];
453 324 if ($is_date) {
454 325 $default_value = accua_forms_filter_date($default_value);
455 - } elseif (!current_user_can('unfiltered_html')) {
326 + } else if (!current_user_can('unfiltered_html')) {
456 327 //This is filtered in any case because field type can change
457 328 $default_value = wp_kses($default_value, 'post');
458 329 }
459 - $draft_data['fields'][$wid]['default_value'] = $default_value;
330 + $forms_data[$fid]['fields'][$wid]['default_value'] = $default_value;
460 331 }
461 332
462 333 if (!empty($post["form-field-{$wid}-override-allowed-values"])) {
463 334 @ $allowed_values = (string) $post["form-field-{$wid}-allowed-values"];
464 335 if ($is_file){
465 - $draft_data['fields'][$wid]['allowed_extensions'] = accua_forms_filter_extensions($allowed_values);
336 + $forms_data[$fid]['fields'][$wid]['allowed_extensions'] = accua_forms_filter_extensions($allowed_values);
466 337 } else {
467 - $draft_data['fields'][$wid]['allowed_values'] = $allowed_values;
338 + $forms_data[$fid]['fields'][$wid]['allowed_values'] = $allowed_values;
468 339 }
469 340 }
470 341 if (!empty($post["form-field-{$wid}-override-datemin-values"])) {
471 342 @ $mindate_values = (string) $post["form-field-{$wid}-min-of-date"];
472 - $draft_data['fields'][$wid]['min_date'] = accua_forms_filter_date($mindate_values);
343 + $forms_data[$fid]['fields'][$wid]['min_date'] = accua_forms_filter_date($mindate_values);
473 344 }
474 345 if (!empty($post["form-field-{$wid}-override-datemax-values"])) {
475 346 @ $maxdate_values = (string) $post["form-field-{$wid}-max-of-date"];
476 - $draft_data['fields'][$wid]['max_date'] = accua_forms_filter_date($maxdate_values);
347 + $forms_data[$fid]['fields'][$wid]['max_date'] = accua_forms_filter_date($maxdate_values);
477 348 }
478 -
479 - // Save post_type for post-select and post-multicheckbox fields
480 - if (isset($post["form-field-{$wid}-post-type"])) {
481 - @ $post_type_value = (string) $post["form-field-{$wid}-post-type"];
482 - // Validate post type
483 - $valid_post_types = get_post_types(array('public' => true));
484 - if (isset($valid_post_types[$post_type_value])) {
485 - $draft_data['fields'][$wid]['post_type'] = $post_type_value;
486 - }
487 - }
488 -
489 - // Save country_code for telephone fields (for libphonenumber validation)
490 - if (isset($post["form-field-{$wid}-country-code"])) {
491 - $country_code = strtoupper(sanitize_text_field($post["form-field-{$wid}-country-code"]));
492 - // Validate against the list of countries
493 - $valid_countries = accua_forms_get_countries();
494 - if (isset($valid_countries[$country_code])) {
495 - $draft_data['fields'][$wid]['country_code'] = $country_code;
496 - }
497 - }
498 -
499 - /**
500 - * Filter field instance data before saving to draft.
501 - *
502 - * @param array $field_instance The field instance data being saved.
503 - * @param string $widget_id The field widget ID.
504 - * @param array $post_data The raw POST data (already stripslashed).
505 - * @param array $field_def The field definition from avail_fields.
506 - */
507 - $draft_data['fields'][$wid] = apply_filters(
508 - 'accua_forms_save_field_data',
509 - $draft_data['fields'][$wid],
510 - $wid,
511 - $post,
512 - isset($avail_fields[$wid]) ? $avail_fields[$wid] : array()
513 - );
514 -
515 - // Save custom CSS class for the field wrapper
516 - if (isset($post["form-field-{$wid}-css-class"])) {
517 - $css_class_raw = sanitize_text_field($post["form-field-{$wid}-css-class"]);
518 - if ($css_class_raw !== '') {
519 - // Sanitize each class individually
520 - $classes = array_filter(array_map('sanitize_html_class', explode(' ', $css_class_raw)));
521 - $draft_data['fields'][$wid]['css_class'] = implode(' ', $classes);
522 - } else {
523 - $draft_data['fields'][$wid]['css_class'] = '';
524 - }
525 - }
526 -
527 - // Save custom CSS ID for the field wrapper
528 - if (isset($post["form-field-{$wid}-css-id"])) {
529 - $css_id_raw = sanitize_text_field($post["form-field-{$wid}-css-id"]);
530 - $draft_data['fields'][$wid]['css_id'] = sanitize_html_class($css_id_raw);
531 - }
532 -
533 - // Save custom required message override
534 - if (!empty($post["form-field-{$wid}-override-required-msg"])) {
535 - $draft_data['fields'][$wid]['custom_required_message'] = sanitize_text_field($post["form-field-{$wid}-custom-required-msg"]);
536 - }
537 -
538 - // Save custom format message override (email/phone)
539 - if (!empty($post["form-field-{$wid}-override-format-msg"])) {
540 - $draft_data['fields'][$wid]['custom_format_message'] = sanitize_text_field($post["form-field-{$wid}-custom-format-msg"]);
541 - }
542 349 } else {
543 - unset($draft_data['fields'][$wid]);
350 + unset($forms_data[$fid]['fields'][$wid]);
544 351 }
545 352
546 - // Save to draft (not to live database)
547 - _accua_forms_save_draft($fid, $draft_data);
353 + update_option('accua_forms_saved_forms', $forms_data);
548 354
549 355 die('1');
550 356 }
551 357
@@ -586,9 +392,9 @@
586 392 $cleaned_extensions = array();
587 393 $mimes = get_allowed_mime_types();
588 394 $extensions = explode("\n", $extensions);
589 395 foreach ($extensions as $extension) {
590 - $extension = strtolower( trim( ltrim( trim( $extension ), '.' ) ) );
396 + $extension = trim($extension);
591 397 if ($extension !== '') {
592 398 foreach ( $mimes as $ext_preg => $mime_match ) {
593 399 $ext_preg = '!^' . $ext_preg . '$!i';
594 400 if ( preg_match( $ext_preg, $extension ) ) {
@@ -612,14 +418,9 @@
612 418 //boolean
613 419 $form_settings[$k] = (bool) $v;
614 420 break;
615 421 case 'layout':
616 - // Only set if valid layout value, otherwise remove to use default
617 - if ($v === 'toplabel' || $v === 'inlinelabel' || $v === 'sidebyside') {
618 - $form_settings[$k] = $v;
619 - } else {
620 - unset($form_settings[$k]); // Reset to default
621 - }
422 + $form_settings[$k] = ($v === 'toplabel') ? 'toplabel' : 'sidebyside';
622 423 break;
623 424 case 'emails_from':
624 425 // single email
625 426 $form_settings[$k] = accua_forms_filter_email($v);
@@ -650,66 +451,8 @@
650 451 }
651 452 return $form_settings;
652 453 }
653 454
654 -/**
655 - * AJAX handler to restore default message values.
656 - *
657 - * Restores the default content for a specific message section:
658 - * - success_message: On-screen success message
659 - * - error_message: On-screen error message
660 - * - admin_emails: Admin notification email (subject + message only)
661 - * - confirmation_emails: Confirmation email (subject + message only)
662 - *
663 - * @since 2.0.0-beta.6
664 - */
665 -add_action('wp_ajax_accua_forms_restore_default_message', 'accua_forms_restore_default_message');
666 -function accua_forms_restore_default_message() {
667 - if (!current_user_can('manage_options')) {
668 - wp_send_json_error(array('message' => __('Permission denied.', 'contact-forms')), 403);
669 - }
670 -
671 - check_ajax_referer('accua_forms_restore_default', 'nonce');
672 -
673 - $message_type = isset($_POST['message_type']) ? sanitize_key($_POST['message_type']) : '';
674 -
675 - // Get default values
676 - $defaults = accua_forms_get_default_form_data();
677 -
678 - // Define which fields to restore for each message type
679 - $restore_map = array(
680 - 'success_message' => array('success_message'),
681 - 'error_message' => array('error_message'),
682 - 'admin_emails' => array('admin_emails_subject', 'admin_emails_message'),
683 - 'confirmation_emails' => array('confirmation_emails_subject', 'confirmation_emails_message'),
684 - );
685 -
686 - if (!isset($restore_map[$message_type])) {
687 - wp_send_json_error(array('message' => __('Invalid message type.', 'contact-forms')), 400);
688 - }
689 -
690 - // Get current form data
691 - $form_data = get_option('accua_forms_default_form_data', array());
692 - if (!is_array($form_data)) {
693 - $form_data = array();
694 - }
695 -
696 - // Restore the specified fields
697 - $restored_values = array();
698 - foreach ($restore_map[$message_type] as $field) {
699 - $form_data[$field] = $defaults[$field];
700 - $restored_values[$field] = $defaults[$field];
701 - }
702 -
703 - // Save updated form data
704 - update_option('accua_forms_default_form_data', $form_data);
705 -
706 - wp_send_json_success(array(
707 - 'message' => __('Default values restored successfully.', 'contact-forms'),
708 - 'values' => $restored_values,
709 - ));
710 -}
711 -
712 455 add_action( 'wp_ajax_accua-save-form-settings', 'accua_forms_save_form_settings');
713 456 function accua_forms_save_form_settings() {
714 457 if (!current_user_can('manage_options')){
715 458 wp_die( -1, 403 );
@@ -717,16 +460,14 @@
717 460 check_ajax_referer('edit_form', '_nonce_edit_form');
718 461
719 462 $post = stripslashes_deep($_POST);
720 463
464 + $forms_data = get_option('accua_forms_saved_forms', array());
721 465 $fid = $post['form-id'];
722 466 if (accua_forms_validate_form_id($fid) !== '') {
723 467 die('-1');
724 468 }
725 469
726 - // Get draft data instead of live data
727 - $draft_data = _accua_forms_get_draft_data($fid);
728 -
729 470 $settings = array(
730 471 'title',
731 472 'success_message',
732 473 'success_message_no_message',
@@ -741,9 +482,8 @@
741 482 'admin_emails_message_no_message',
742 483 'confirmation_emails_subject',
743 484 'confirmation_emails_message',
744 485 'confirmation_emails_message_no_message',
745 - 'gads_conversion_tracking_code',
746 486 //'use_ajax',
747 487
748 488 'layout',
749 489 'style_margin',
@@ -767,11 +507,8 @@
767 507 'style_submit_background_color',
768 508 'style_submit_padding',
769 509 'style_submit_color',
770 510 'style_submit_font_size',
771 - 'submission_retention_value',
772 - 'submission_retention_unit',
773 - 'submission_retention_mode',
774 511 );
775 512
776 513 // print_r($post);
777 514
@@ -779,215 +516,22 @@
779 516 foreach($settings as $i) {
780 517 if (isset($post[$i])) {
781 518 $new_form_settings[$i] = $post[$i];
782 519 }
783 - if (isset($draft_data[$i])) {
784 - unset($draft_data[$i]);
785 - }
520 + unset($forms_data[$fid][$i]);
786 521 }
787 522
788 - $draft_data += accua_forms_filter_settings($new_form_settings);
523 + $forms_data[$fid] += accua_forms_filter_settings($new_form_settings);
789 524
790 - $draft_data['use_ajax'] = !empty($post['use_ajax']);
791 - $draft_data['submission_retention_override'] = !empty($post['submission_retention_override']);
525 + $forms_data[$fid]['use_ajax'] = !empty($post['use_ajax']);
792 526
793 - // Save to draft (not to live database)
794 - _accua_forms_save_draft($fid, $draft_data);
527 + update_option('accua_forms_saved_forms', $forms_data);
795 528
796 - // Return JSON response for AJAX handler
797 - wp_send_json_success($draft_data);
798 -}
529 + //print_r($forms_data[$fid]);
799 530
800 -/**
801 - * AJAX handler to publish draft to live database.
802 - * Called when user clicks the Save button.
803 - */
804 -add_action( 'wp_ajax_accua-publish-form-draft', 'accua_forms_publish_form_draft');
805 -function accua_forms_publish_form_draft() {
806 - if (!current_user_can('manage_options')){
807 - wp_die( -1, 403 );
808 - }
809 - check_ajax_referer('edit_form', '_nonce_edit_form');
810 -
811 - $post = stripslashes_deep($_POST);
812 - $fid = isset($post['form-id']) ? $post['form-id'] : '';
813 -
814 - if (accua_forms_validate_form_id($fid) !== '') {
815 - wp_send_json_error(array('message' => __('Invalid form ID.', 'contact-forms')), 400);
816 - }
817 -
818 - // Publish the draft
819 - $result = _accua_forms_publish_draft($fid);
820 -
821 - if ($result) {
822 - wp_send_json_success(array('message' => __('Form saved successfully.', 'contact-forms')));
823 - } else {
824 - // Draft might not exist (nothing to publish) - this is OK for a new form
825 - // Check if form exists in database
826 - $forms_data = get_option('accua_forms_saved_forms', array());
827 - if (isset($forms_data[$fid])) {
828 - wp_send_json_success(array('message' => __('No changes to save.', 'contact-forms')));
829 - } else {
830 - wp_send_json_error(array('message' => __('Failed to save form.', 'contact-forms')), 500);
831 - }
832 - }
531 + die('');
833 532 }
834 533
835 -/**
836 - * AJAX handler to discard draft and reload from published data.
837 - * Called when user clicks "Discard changes".
838 - */
839 -add_action( 'wp_ajax_accua-discard-form-draft', 'accua_forms_discard_form_draft');
840 -function accua_forms_discard_form_draft() {
841 - if (!current_user_can('manage_options')){
842 - wp_die( -1, 403 );
843 - }
844 - check_ajax_referer('edit_form', '_nonce_edit_form');
845 -
846 - $post = stripslashes_deep($_POST);
847 - $fid = isset($post['form-id']) ? $post['form-id'] : '';
848 -
849 - if (accua_forms_validate_form_id($fid) !== '') {
850 - wp_send_json_error(array('message' => __('Invalid form ID.', 'contact-forms')), 400);
851 - }
852 -
853 - // Delete the draft
854 - _accua_forms_delete_draft($fid);
855 -
856 - wp_send_json_success(array('message' => __('Changes discarded.', 'contact-forms')));
857 -}
858 -
859 -/**
860 - * AJAX handler to get posts for post-select fields with pagination.
861 - * Available to both logged-in and anonymous users (for frontend forms).
862 - *
863 - * @since 2.0.0-beta.29
864 - */
865 -add_action('wp_ajax_accua_forms_get_posts', 'accua_forms_ajax_get_posts');
866 -add_action('wp_ajax_nopriv_accua_forms_get_posts', 'accua_forms_ajax_get_posts');
867 -function accua_forms_ajax_get_posts() {
868 - // Verify nonce
869 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Nonce verification
870 - if (!isset($_REQUEST['_nonce']) || !wp_verify_nonce($_REQUEST['_nonce'], 'accua_forms_get_posts')) {
871 - wp_send_json_error(array('message' => __('Security check failed.', 'contact-forms')), 403);
872 - }
873 -
874 - // Sanitize inputs
875 - $post_type = isset($_REQUEST['post_type']) ? sanitize_text_field(wp_unslash($_REQUEST['post_type'])) : 'page';
876 - $search = isset($_REQUEST['search']) ? sanitize_text_field(wp_unslash($_REQUEST['search'])) : '';
877 - $page = isset($_REQUEST['page']) ? absint($_REQUEST['page']) : 1;
878 - $per_page = isset($_REQUEST['per_page']) ? min(absint($_REQUEST['per_page']), 100) : 50;
879 - $extra_args = isset($_REQUEST['extra_args']) ? sanitize_text_field(wp_unslash($_REQUEST['extra_args'])) : '';
880 - $selected = isset($_REQUEST['selected']) ? sanitize_text_field(wp_unslash($_REQUEST['selected'])) : '';
881 -
882 - // Validate post type
883 - $valid_post_types = get_post_types(array('public' => true));
884 - if (!isset($valid_post_types[$post_type])) {
885 - $post_type = 'page';
886 - }
887 -
888 - // Calculate offset
889 - $offset = ($page - 1) * $per_page;
890 -
891 - // Build query arguments
892 - $args = array(
893 - 'post_type' => $post_type,
894 - 'number' => $per_page + 1, // Get one extra to check if there are more
895 - 'offset' => $offset,
896 - 's' => $search,
897 - );
898 -
899 - // Parse extra arguments (backward compatibility with allowed_values textarea)
900 - if (!empty($extra_args)) {
901 - // Parse the query string format
902 - $extra = array();
903 - wp_parse_str($extra_args, $extra);
904 -
905 - // Allow post_type override from extra_args (backward compatibility)
906 - if (isset($extra['post_type'])) {
907 - $override_post_type = sanitize_text_field($extra['post_type']);
908 - // Validate the overridden post type
909 - if (isset($valid_post_types[$override_post_type])) {
910 - $post_type = $override_post_type;
911 - $args['post_type'] = $post_type;
912 - }
913 - }
914 -
915 - // Merge only safe parameters
916 - $safe_params = array('meta_key', 'meta_value', 'authors', 'parent', 'child_of', 'exclude', 'include', 'sort_column', 'sort_order');
917 - foreach ($safe_params as $param) {
918 - if (isset($extra[$param])) {
919 - $args[$param] = $extra[$param];
920 - }
921 - }
922 - }
923 -
924 - // Get posts using WPML-compatible function
925 - $posts = accua_get_pages($args);
926 -
927 - // Check if there are more results
928 - $has_more = count($posts) > $per_page;
929 - if ($has_more) {
930 - array_pop($posts); // Remove the extra item
931 - }
932 -
933 - // Format results for the dropdown
934 - $results = array();
935 - foreach ($posts as $post) {
936 - $results[] = array(
937 - 'id' => $post->ID,
938 - 'text' => $post->post_title,
939 - );
940 - }
941 -
942 - // If this is the first page and we have a selected value, ensure it's in the list
943 - if ($page === 1 && !empty($selected) && is_numeric($selected)) {
944 - $selected_id = absint($selected);
945 - $found = false;
946 - foreach ($results as $result) {
947 - if ($result['id'] === $selected_id) {
948 - $found = true;
949 - break;
950 - }
951 - }
952 - // If selected post not in results, fetch it separately and prepend
953 - if (!$found) {
954 - $selected_post = get_post($selected_id);
955 - if ($selected_post && $selected_post->post_type === $post_type) {
956 - array_unshift($results, array(
957 - 'id' => $selected_post->ID,
958 - 'text' => $selected_post->post_title,
959 - ));
960 - }
961 - }
962 - }
963 -
964 - wp_send_json_success(array(
965 - 'results' => $results,
966 - 'more' => $has_more,
967 - 'page' => $page,
968 - ));
969 -}
970 -
971 -/**
972 - * Get available public post types for the post-select field editor.
973 - *
974 - * @since 2.0.0-beta.29
975 - * @return array Array of post type slug => label pairs.
976 - */
977 -function accua_forms_get_public_post_types() {
978 - $post_types = get_post_types(array('public' => true), 'objects');
979 - $options = array();
980 - foreach ($post_types as $post_type) {
981 - // Skip attachments
982 - if ($post_type->name === 'attachment') {
983 - continue;
984 - }
985 - $options[$post_type->name] = $post_type->labels->singular_name;
986 - }
987 - return $options;
988 -}
989 -
990 534 function accua_forms_field_settings_form_counter() {
991 535 static $i = 0;
992 536 $i++;
993 537 return $i;
@@ -1027,10 +571,8 @@
1027 571 $override_label = isset($istance_data['label']) ? 'checked="checked"' : '';
1028 572 $override_default_value = isset($istance_data['default_value']) ? 'checked="checked"' : '';
1029 573 $override_allowed_values = isset($istance_data['allowed_values']) ? 'checked="checked"' : '';
1030 574 $override_allowed_extensions = '';
1031 - $override_custom_required_msg = isset($istance_data['custom_required_message']) ? 'checked="checked"' : '';
1032 - $override_custom_format_msg = isset($istance_data['custom_format_message']) ? 'checked="checked"' : '';
1033 575
1034 576 if ($field_data['type'] == 'file') {
1035 577 if (isset($istance_data['version']) && $istance_data['version'] >= 2) {
1036 578 if (isset($istance_data['allowed_extensions'])) {
@@ -1076,21 +618,16 @@
1076 618 'default_value' => $field_data['default_value'],
1077 619 'allowed_values' => $field_data['allowed_values'],
1078 620 'allowed_extensions' => $field_data['allowed_extensions'],
1079 621 'required' => false,
1080 - 'post_type' => 'page', // Default post type for post-select fields
1081 - 'css_class' => '',
1082 - 'css_id' => '',
1083 - 'custom_required_message' => '',
1084 - 'custom_format_message' => '',
1085 622 );
1086 623
1087 624 foreach ($istance_data as $key => $value) {
1088 - $istance_data[$key] = esc_attr($istance_data[$key]);
625 + $istance_data[$key] = htmlspecialchars($istance_data[$key], ENT_QUOTES);
1089 626 }
1090 627
1091 628 foreach ($field_data as $key => $value) {
1092 - $field_data[$key] = esc_attr($field_data[$key]);
629 + $field_data[$key] = htmlspecialchars($field_data[$key], ENT_QUOTES);
1093 630 }
1094 631
1095 632 $multi_number = '';
1096 633 $add_new = '';
@@ -1111,9 +648,9 @@
1111 648 $forceoverride_field = false;
1112 649 $add_new = $empty_istance ? 'single' : '';
1113 650 }
1114 651
1115 - $fid = esc_attr($fid);
652 + $fid = htmlspecialchars($fid, ENT_QUOTES);
1116 653 $testi_eot = array (
1117 654 'label' => __( 'Label', 'contact-forms'),
1118 655 'override' => __( 'override', 'contact-forms'),
1119 656 'default_value' => __( 'Default value', 'contact-forms'),
@@ -1124,10 +661,8 @@
1124 661 'allowed_extensions' => __( 'Allowed extensions', 'contact-forms'),
1125 662 'desc_all_ext' => __( 'Accepted file extensions. One per line, without dots.', 'contact-forms'),
1126 663 'required' => __( 'Required', 'contact-forms'),
1127 664 'custom_HTML_content' => __( 'Custom HTML content', 'contact-forms'),
1128 - 'refresh_preview' => __( 'Refresh Preview', 'contact-forms'),
1129 - 'add' => __( 'Add field', 'contact-forms'),
1130 665 'remove' => __( 'Remove', 'contact-forms'),
1131 666 'close' => __( 'Close', 'contact-forms'),
1132 667 'save' => __( 'Save', 'contact-forms'),
1133 668 'min-of-date' => __( 'Min date', 'contact-forms'),
@@ -1143,9 +678,8 @@
1143 678 $override_type = 'checkbox';
1144 679 $override_end = ')';
1145 680 }
1146 681
1147 - // phpcs:disable PluginCheck.CodeAnalysis.Heredoc.NotAllowed, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped -- Heredoc used for HTML templates with pre-escaped variables
1148 682 $content = <<<EOT
1149 683 <p><label for="widget-{$istance_data['istance_id']}-label">{$testi_eot['label']}:</label>
1150 684 {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-label" value="1" {$override_label} />{$override_end}<br>
1151 685 <input type="text" value="{$istance_data['label']}" name="form-field-{$istance_data['istance_id']}-label" id="widget-{$istance_data['istance_id']}-label" class="widefat"></p>
@@ -1183,43 +717,8 @@
1183 717 <p><label for="widget-{$istance_data['istance_id']}-required">{$testi_eot['required']}:</label>
1184 718 <input type="checkbox" value="1" {$required_checked} name="form-field-{$istance_data['istance_id']}-required" id="widget-{$istance_data['istance_id']}-required"></p>
1185 719 EOT;
1186 720
1187 - // Custom required message override (checkbox + text input, same pattern as custom label)
1188 - $custom_required_msg_label = __( 'Custom required message', 'contact-forms');
1189 - // translators: %s is the field name/label
1190 - $custom_required_msg_desc = __( 'Overrides the default "required" error message. Use %s for the field name.', 'contact-forms');
1191 - $custom_required_msg = <<<EOT
1192 - <p><label for="widget-{$istance_data['istance_id']}-custom-required-msg">{$custom_required_msg_label}:</label>
1193 - {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-required-msg" value="1" {$override_custom_required_msg} />{$override_end}<br>
1194 - <input type="text" value="{$istance_data['custom_required_message']}" name="form-field-{$istance_data['istance_id']}-custom-required-msg" id="widget-{$istance_data['istance_id']}-custom-required-msg" class="widefat"><br>
1195 - <small>{$custom_required_msg_desc}</small></p>
1196 -EOT;
1197 -
1198 - // Custom format message override for email and telephone fields
1199 - $custom_format_msg = '';
1200 - if ($field_data['type'] === 'email' || $field_data['type'] === 'autoreply_email') {
1201 - $custom_format_msg_label = __( 'Custom invalid email message', 'contact-forms');
1202 - // translators: %s is the field name/label
1203 - $custom_format_msg_desc = __( 'Overrides the default email format error message. Use %s for the field name.', 'contact-forms');
1204 - $custom_format_msg = <<<EOT
1205 - <p><label for="widget-{$istance_data['istance_id']}-custom-format-msg">{$custom_format_msg_label}:</label>
1206 - {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-format-msg" value="1" {$override_custom_format_msg} />{$override_end}<br>
1207 - <input type="text" value="{$istance_data['custom_format_message']}" name="form-field-{$istance_data['istance_id']}-custom-format-msg" id="widget-{$istance_data['istance_id']}-custom-format-msg" class="widefat"><br>
1208 - <small>{$custom_format_msg_desc}</small></p>
1209 -EOT;
1210 - } elseif ($field_data['type'] === 'telephone') {
1211 - $custom_format_msg_label = __( 'Custom invalid phone message', 'contact-forms');
1212 - // translators: %s is the field name/label
1213 - $custom_format_msg_desc = __( 'Overrides the default phone format error message. Use %s for the field name.', 'contact-forms');
1214 - $custom_format_msg = <<<EOT
1215 - <p><label for="widget-{$istance_data['istance_id']}-custom-format-msg">{$custom_format_msg_label}:</label>
1216 - {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-format-msg" value="1" {$override_custom_format_msg} />{$override_end}<br>
1217 - <input type="text" value="{$istance_data['custom_format_message']}" name="form-field-{$istance_data['istance_id']}-custom-format-msg" id="widget-{$istance_data['istance_id']}-custom-format-msg" class="widefat"><br>
1218 - <small>{$custom_format_msg_desc}</small></p>
1219 -EOT;
1220 - }
1221 -
1222 721 if ($field_data['type'] == 'date'){
1223 722 $default_date_value = <<<EOT
1224 723 <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label>
1225 724 {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />{$override_end}<br>
@@ -1236,76 +735,8 @@
1236 735 <input type="date" value="{$istance_data['max_date']}" name="form-field-{$istance_data['istance_id']}-max-of-date" id="widget-{$istance_data['istance_id']}-max-of-date"></p>
1237 736 EOT;
1238 737 }
1239 738
1240 - // Post type selector for post-select and post-multicheckbox fields
1241 - $post_type_selector = '';
1242 - if ($field_data['type'] === 'post-select' || $field_data['type'] === 'post-multicheckbox') {
1243 - $override_post_type = isset($istance_data['post_type']) && $istance_data['post_type'] !== 'page' ? 'checked="checked"' : '';
1244 - $post_types = accua_forms_get_public_post_types();
1245 - $post_type_options = '';
1246 - $current_post_type = esc_attr($istance_data['post_type']);
1247 - foreach ($post_types as $pt_slug => $pt_label) {
1248 - $selected = ($pt_slug === $current_post_type) ? ' selected="selected"' : '';
1249 - $post_type_options .= '<option value="' . esc_attr($pt_slug) . '"' . $selected . '>' . esc_html($pt_label) . '</option>';
1250 - }
1251 - $post_type_label = __('Post type', 'contact-forms');
1252 - $post_type_desc = __('Select which post type to show in the dropdown.', 'contact-forms');
1253 - $query_params_label = __('Additional query parameters', 'contact-forms');
1254 - // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- This is example help text, not actual code.
1255 - $query_params_desc = __('Optional: Filter posts using query parameters (e.g., authors=admin or meta_key=featured&meta_value=1). Leave empty for all posts of the selected type.', 'contact-forms');
1256 - $post_type_selector = <<<EOT
1257 - <p><label for="widget-{$istance_data['istance_id']}-post-type">{$post_type_label}:</label>
1258 - {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-post-type" value="1" {$override_post_type} />{$override_end}<br>
1259 - <select name="form-field-{$istance_data['istance_id']}-post-type" id="widget-{$istance_data['istance_id']}-post-type" class="widefat">{$post_type_options}</select><br />
1260 - {$post_type_desc}</p>
1261 - <p><label for="widget-{$istance_data['istance_id']}-allowed-values">{$query_params_label}:</label>
1262 - {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-allowed-values" value="1" {$override_allowed_values} />{$override_end}<br>
1263 - <textarea rows="3" cols="50" name="form-field-{$istance_data['istance_id']}-allowed-values" id="widget-{$istance_data['istance_id']}-allowed-values" class="widefat">{$istance_data['allowed_values']}</textarea><br />
1264 - {$query_params_desc}</p>
1265 -EOT;
1266 - }
1267 -
1268 - // Country selector for telephone fields (for libphonenumber validation)
1269 - $country_selector = '';
1270 - if ($field_data['type'] === 'telephone') {
1271 - $countries = accua_forms_get_countries();
1272 - $current_country = isset($istance_data['country_code']) ? esc_attr($istance_data['country_code']) : 'IT';
1273 - $override_country = isset($istance_data['country_code']) && $istance_data['country_code'] !== 'IT' ? 'checked="checked"' : '';
1274 - $country_options = '';
1275 - foreach ($countries as $code => $country_name) {
1276 - $selected = ($code === $current_country) ? ' selected="selected"' : '';
1277 - $country_options .= '<option value="' . esc_attr($code) . '"' . $selected . '>' . esc_html($country_name) . '</option>';
1278 - }
1279 - $country_label = __('Default country', 'contact-forms');
1280 - // translators: Help text for phone field country selector in form editor
1281 - $country_desc = __('For numbers without international prefix, validation assumes this country.', 'contact-forms');
1282 - $country_selector = <<<EOT
1283 - <p><label for="widget-{$istance_data['istance_id']}-country-code">{$country_label}:</label>
1284 - {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-country-code" value="1" {$override_country} />{$override_end}<br>
1285 - <select name="form-field-{$istance_data['istance_id']}-country-code" id="widget-{$istance_data['istance_id']}-country-code" class="widefat">{$country_options}</select><br />
1286 - {$country_desc}</p>
1287 -EOT;
1288 - }
1289 -
1290 - // CSS Class and CSS ID fields (universal, apply to all field types)
1291 - $css_class_label = __( 'CSS Class', 'contact-forms');
1292 - $css_id_label = __( 'CSS ID', 'contact-forms');
1293 - // translators: Help text for CSS Class field in form editor
1294 - $css_class_desc = __( 'Custom CSS class(es) for the field wrapper. Separate multiple classes with spaces.', 'contact-forms');
1295 - // translators: Help text for CSS ID field in form editor
1296 - $css_id_desc = __( 'Custom CSS ID for the field wrapper. Must be unique on the page.', 'contact-forms');
1297 - $css_class_field = <<<EOT
1298 - <p><label for="widget-{$istance_data['istance_id']}-css-class">{$css_class_label}:</label><br>
1299 - <input type="text" value="{$istance_data['css_class']}" name="form-field-{$istance_data['istance_id']}-css-class" id="widget-{$istance_data['istance_id']}-css-class" class="widefat"><br>
1300 - <small>{$css_class_desc}</small></p>
1301 -EOT;
1302 - $css_id_field = <<<EOT
1303 - <p><label for="widget-{$istance_data['istance_id']}-css-id">{$css_id_label}:</label><br>
1304 - <input type="text" value="{$istance_data['css_id']}" name="form-field-{$istance_data['istance_id']}-css-id" id="widget-{$istance_data['istance_id']}-css-id" class="widefat"><br>
1305 - <small>{$css_id_desc}</small></p>
1306 -EOT;
1307 -
1308 739 switch ($field_data['type']) {
1309 740 case 'textarea':
1310 741 $content .= <<<EOT
1311 742 <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label>
@@ -1311,9 +742,8 @@
1311 742 <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label>
1312 743 {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />{$override_end}<br>
1313 744 <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat">{$istance_data['default_value']}</textarea></p>
1314 745 $required
1315 - $custom_required_msg
1316 746 EOT;
1317 747 break;
1318 748 case 'hidden':
1319 749 $content = $default_value;
@@ -1318,34 +748,26 @@
1318 748 case 'hidden':
1319 749 $content = $default_value;
1320 750 break;
1321 751 case 'checkbox':
1322 - $content .= $default_value . $required . $custom_required_msg;
752 + $content .= $default_value . $required;
1323 753 break;
1324 754 case 'select':
1325 755 case 'radio':
1326 - $content .= $default_value . $allowed_values . $required . $custom_required_msg;
1327 - break;
1328 756 case 'post-select':
1329 - $content .= $default_value . $post_type_selector . $required . $custom_required_msg;
757 + $content .= $default_value . $allowed_values . $required;
1330 758 break;
1331 759 case 'multiselect':
1332 760 case 'multicheckbox':
1333 - $content .= $default_values . $allowed_values . $required . $custom_required_msg;
1334 - break;
1335 761 case 'post-multicheckbox':
1336 - $content .= $default_values . $post_type_selector . $required . $custom_required_msg;
762 + $content .= $default_values . $allowed_values . $required;
1337 763 break;
1338 764 case 'file':
1339 - $content .= $allowed_ext . $required . $custom_required_msg;
1340 - break;
765 + $content .= $allowed_ext . $required;
1341 766 case 'submit':
767 + case 'fieldset-begin':
1342 768 //just the label
1343 769 break;
1344 - case 'fieldset-begin':
1345 - //just the label + css fields
1346 - $content .= $css_class_field . $css_id_field;
1347 - break;
1348 770 case 'fieldset-end':
1349 771 //Nothing!
1350 772 $content = '';
1351 773 break;
@@ -1353,52 +775,28 @@
1353 775 $content = <<<EOT
1354 776 <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['custom_HTML_content']}</label>
1355 777 {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />{$override_end}<br>
1356 778 <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat">{$istance_data['default_value']}</textarea></p>
1357 - <p><a href="#" class="accua-refresh-preview">{$testi_eot['refresh_preview']}</a></p>
1358 779 EOT;
1359 780 break;
1360 781 case 'date':
1361 - $content .= $default_date_value . $min_date . $max_date . $required . $custom_required_msg;
782 + $content .= $default_date_value . $min_date . $max_date . $required;
1362 783 break;
1363 - case 'telephone':
1364 - $content .= $default_value . $country_selector . $required . $custom_required_msg . $custom_format_msg;
1365 - break;
1366 784 case 'email':
1367 785 case 'autoreply_email':
1368 - $content .= $default_value . $required . $custom_required_msg . $custom_format_msg;
1369 - break;
1370 786 case 'textfield':
1371 787 case 'colorpicker':
1372 788 case 'datepicker':
1373 789 case 'dateselect':
1374 790 default:
1375 - /**
1376 - * Action to render additional field settings in the form editor.
1377 - *
1378 - * @param string $field_type The field type identifier.
1379 - * @param array $field_data The field definition.
1380 - * @param array $istance_data The field instance data.
1381 - * @param string $content The current settings HTML (passed by reference via output buffering).
1382 - */
1383 - ob_start();
1384 - do_action( 'accua_forms_field_settings', $field_data['type'], $field_data, $istance_data );
1385 - $extra_settings = ob_get_clean();
1386 - $content .= $default_value . $extra_settings . $required . $custom_required_msg;
791 + $content .= $default_value . $required;
1387 792 break;
1388 793 }
1389 -
1390 - // Append CSS Class and CSS ID fields to all types except fieldset-end (which has no settings)
1391 - if ($field_data['type'] !== 'fieldset-end' && $field_data['type'] !== 'fieldset-begin') {
1392 - $content .= $css_class_field . $css_id_field;
1393 - }
1394 -
1395 794 $adminurl = admin_url();
1396 795
1397 796 return <<<EOT
1398 797 <div class="widget ui-draggable" id="widget-{$i}_{$istance_data['istance_id']}" $hidden> <div class="widget-top">
1399 798 <div class="widget-title-action">
1400 - <a href="#add-field" class="widget-add-action hide-if-no-js" title="{$testi_eot['add']}" aria-label="{$testi_eot['add']}"></a>
1401 799 <a href="#available-widgets" class="widget-action hide-if-no-js"></a>
1402 800 </div>
1403 801 <div class="widget-title"><h4>{$field_data['name']}<span class="in-widget-title"></span></h4></div>
1404 802 </div>
@@ -1422,9 +820,10 @@
1422 820 <a href="#remove" class="widget-control-remove delete">{$testi_eot['remove']}</a> |
1423 821 <a href="#close" class="widget-control-close">{$testi_eot['close']}</a>
1424 822 </div>
1425 823 <div class="alignright">
1426 - <input type="submit" value="{$testi_eot['save']}" class="button button-primary widget-control-save accua-field-save-btn" id="widget-{$istance_data['istance_id']}-savewidget" name="savewidget">
824 + <img alt="" title="" class="ajax-feedback" src="{$adminurl}images/wpspin_light.gif">
825 + <input type="submit" value="{$testi_eot['save']}" class="button-primary widget-control-save" id="widget-{$istance_data['istance_id']}-savewidget" name="savewidget">
1427 826 </div>
1428 827 <br class="clear">
1429 828 </div>
1430 829 </form>
@@ -1435,18 +834,15 @@
1435 834 </div>-->
1436 835 </div>
1437 836
1438 837 EOT;
1439 - // phpcs:enable PluginCheck.CodeAnalysis.Heredoc.NotAllowed, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped
1440 838 }
1441 839
1442 840 function accua_forms_add_page($message='') {
1443 841 $forms_data = get_option('accua_forms_saved_forms', array());
1444 842 $trash_data = get_option('accua_forms_trash_forms', array());
1445 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only form ID, parent function accua_forms_list_page() checks nonce
1446 843 if (!empty($_GET['fid'])) {
1447 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only form ID
1448 - $fid = absint(wp_unslash($_GET['fid']));
844 + $fid = htmlspecialchars(stripslashes($_GET['fid']), ENT_QUOTES);
1449 845 } else {
1450 846 if ($message === '') {
1451 847 $fid = 1 + ((int) get_option('accua_forms_lastid', 0));
1452 848 while (isset($forms_data[$fid]) || isset($trash_data[$fid])) {
@@ -1462,9 +858,9 @@
1462 858 }
1463 859 }
1464 860 if (!empty($_GET['clonefrom'])) {
1465 861 check_admin_referer('clone_posts');
1466 - $clonefrom = sanitize_text_field( wp_unslash( $_GET['clonefrom'] ) );
862 + $clonefrom = stripslashes($_GET['clonefrom']);
1467 863 } else {
1468 864 $clonefrom = '';
1469 865 }
1470 866 ?>
@@ -1469,70 +865,49 @@
1469 865 }
1470 866 ?>
1471 867
1472 868 <div id="accua_forms_add_page" class="accua_forms_admin_page wrap">
1473 -<h1><?php esc_html_e( 'Create a form', 'contact-forms'); ?></h1>
869 +<h2><?php _e( 'Create a form', 'contact-forms'); ?> </h2>
1474 870 <?php if ($message !== '') {
1475 - echo "<div style='border:1px solid; padding: 10px;'>".esc_html($message)."</div>";
871 + echo "<div style='border:1px solid; padding: 10px;'>$message</div>";
1476 872 } ?>
1477 873 <form action="admin.php" method="GET">
1478 874 <?php wp_nonce_field('edit_posts', '_wpnonce', false, true) ?>
1479 875 <input type="hidden" name="page" value="accua_forms_list" />
1480 -<p>Form id: <input type="text" name="fid" value="<?php echo esc_attr($fid); ?>" /></p>
876 +<p>Form id: <input type="text" name="fid" value="<?php echo $fid; ?>" /></p>
1481 877 <?php
1482 878 if ($forms_data) {
1483 879 echo '<p><select name="clonefrom">
1484 - <option value="">'.esc_html__( 'Empty form', 'contact-forms').'</option>
1485 - <optgroup label="'.esc_attr__( 'Clone form:', 'contact-forms').'">';
880 + <option value="">'.__( 'Empty form', 'contact-forms').'</option>
881 + <optgroup label="'.__( 'Clone form:', 'contact-forms').'">';
1486 882 foreach ($forms_data as $i => $formdata) {
1487 - $sel = ( $i === $clonefrom ) ? ' selected="selected"' : '';
1488 - $i_esc = esc_attr($i);
883 + $sel = ($i == $clonefrom) ? " selected='selected'" : '';
884 + $i = htmlspecialchars($i, ENT_QUOTES);
1489 885 if (isset($formdata['title']) && ('' !== trim($formdata['title']))) {
1490 - $formtitle = esc_html($formdata['title']);
886 + $formtitle = htmlspecialchars($formdata['title']);
1491 887 } else {
1492 - $formtitle = $i_esc;
888 + $formtitle = $i;
1493 889 }
1494 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $sel is a static string, other vars pre-escaped
1495 - echo '<option value="' . esc_attr( $i_esc ) . '"' . $sel . '>' . esc_html( $formtitle ) . "</option>\n";
890 + echo "<option value='$i'$sel>$formtitle</option>\n";
1496 891 }
1497 892 echo '</optgroup></select></p>';
1498 893 }
1499 894 ?>
1500 -<p><input type="submit" value="<?php esc_attr_e( 'Create', 'contact-forms'); ?>" /></p>
895 +<p><input type="submit" value="<?php _e( 'Create', 'contact-forms'); ?>" /></p>
1501 896 </form>
1502 897 </div>
1503 898 <?php
1504 899 }
1505 900
1506 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function, underscore prefix indicates private
1507 901 function _accua_forms_test_clonefrom($fid){
1508 902 $error = '';
1509 903 if (isset($_GET['clonefrom'])&&$_GET['clonefrom']!=='') {
1510 - // Verify nonce for clone operation to prevent CSRF attacks
1511 - // Check for both possible nonce actions depending on the entry point
1512 - $nonce_valid = false;
1513 - if (isset($_GET['_wpnonce'])) {
1514 - $nonce = sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) );
1515 - // First try clone_posts nonce (from accua_forms_add page)
1516 - if (wp_verify_nonce($nonce, 'clone_posts')) {
1517 - $nonce_valid = true;
1518 - }
1519 - // Then try edit_posts nonce (from accua_forms_list page)
1520 - elseif (wp_verify_nonce($nonce, 'edit_posts')) {
1521 - $nonce_valid = true;
1522 - }
1523 - }
1524 -
1525 - if (!$nonce_valid) {
1526 - wp_die(esc_html__('Security check failed. Please try again.', 'contact-forms'), esc_html__('Security Error', 'contact-forms'), array('response' => 403));
1527 - }
1528 -
1529 - $clonefrom = sanitize_text_field( wp_unslash( $_GET['clonefrom'] ) );
904 + $clonefrom = stripslashes($_GET['clonefrom']);
1530 905 $forms_data = get_option('accua_forms_saved_forms', array());
1531 906 if (isset($forms_data[$fid])){
1532 - $error .= '<p>' . esc_html__( 'Form already exists', 'contact-forms') . '</p>';
1533 - } elseif (empty($forms_data[$clonefrom])) {
1534 - $error .= '<p>' . esc_html__( 'Source form doesn\'t exists.', 'contact-forms') . '</p>';
907 + $error .= "<p>".__( 'Form already exists', 'contact-forms')."</p>";
908 + } else if (empty($forms_data[$clonefrom])) {
909 + $error .= "<p>".__( 'Source form doesn\'t exists.', 'contact-forms')."</p>";
1535 910 } else {
1536 911 $forms_data[$fid] = $forms_data[$clonefrom];
1537 912 if (!isset($forms_data[$fid]['title'])) {
1538 913 $forms_data[$fid]['title'] = $clonefrom ." ".__( 'clone', 'contact-forms');
@@ -1544,9 +919,8 @@
1544 919 }
1545 920 return $error;
1546 921 }
1547 922
1548 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function, underscore prefix indicates private
1549 923 function _accua_forms_form_edit_action() {
1550 924 static $message = null;
1551 925 if ($message === null) {
1552 926 $message = '';
@@ -1558,10 +932,9 @@
1558 932 check_admin_referer('contact-forms-delete_'.$fid);
1559 933 $forms_data = get_option('accua_forms_saved_forms', array());
1560 934 unset($forms_data[$fid]);
1561 935 update_option('accua_forms_saved_forms', $forms_data);
1562 - $fid = esc_html($fid);
1563 - // translators: %s is the form ID being deleted
936 + $fid = htmlspecialchars($fid);
1564 937 $message .= sprintf( __( 'Form "%s" deleted','contact-forms' ), $fid );
1565 938 break;
1566 939 }
1567 940 }
@@ -1571,15 +944,15 @@
1571 944
1572 945 function accua_forms_validate_form_id($fid) {
1573 946 $error = '';
1574 947 if (!preg_match('/^[a-z0-9_-]+$/i', $fid)) {
1575 - $error .= "<p>".__( 'Only letters, numbers, hyphens, and underscores allowed in form identifier', 'contact-forms')."</p>";
948 + $error .= "<p>".__( 'Only letters, numbers, hyphen and underscores allowed in form identificative name', 'contact-forms')."</p>";
1576 949 }
1577 950 if (substr($fid,0,2) == '__') {
1578 - $error .= "<p>".__( 'The identifier cannot start with two underscores (__)', 'contact-forms')."</p>";
951 + $error .= "<p>".__( 'The identificative name can\'t start with two underscores (__)', 'contact-forms')."</p>";
1579 952 }
1580 953 if (strlen($fid) > 70) {
1581 - $error .= "<p>".__( 'The identifier cannot be longer than 70 characters', 'contact-forms')."</p>";
954 + $error .= "<p>".__( 'You cannot use more than 70 characters for the identificative name', 'contact-forms')."</p>";
1582 955 }
1583 956 return $error;
1584 957 }
1585 958
@@ -1584,17 +957,15 @@
1584 957 }
1585 958
1586 959 function accua_forms_list_page() {
1587 960 $message = '';
1588 - // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified below
1589 961 if (isset($_POST['accua-form-edit-action'])){
1590 962 $message = _accua_forms_form_edit_action();
1591 - } elseif (isset($_GET['fid'])) {
963 + } else if (isset($_GET['fid'])) {
1592 964 check_admin_referer('edit_posts');
1593 - $fid = sanitize_text_field(wp_unslash($_GET['fid']));
965 + $fid = stripslashes($_GET['fid']);
1594 966 $error = accua_forms_validate_form_id($fid);
1595 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verified above
1596 - if ($error === '' && (isset($_GET['clonefrom']) && $_GET['clonefrom'] !== '')) {
967 + if ($error === '' && (isset($_GET['clonefrom'])&&$_GET['clonefrom']!=='')) {
1597 968 $error .= _accua_forms_test_clonefrom($fid);
1598 969 }
1599 970 if ($error === '') {
1600 971 return accua_forms_edit_page($fid);
@@ -1604,14 +975,18 @@
1604 975 }
1605 976 ?>
1606 977 <div id="accua_forms_list_page" class="accua_forms_admin_page wrap">
1607 978 <?php if ($message !== '') {
1608 - echo "<div style='border:1px solid; padding: 10px;'>".esc_html($message)."</div>";
979 + echo "<div style='border:1px solid; padding: 10px;'>$message</div>";
1609 980 } ?>
1610 -<h1 class="wp-heading-inline"><?php esc_html_e( 'Contact Forms', 'contact-forms'); ?></h1>
1611 -<a class="page-title-action" href="<?php echo esc_url( get_admin_url() ); ?>admin.php?page=accua_forms_add"><?php esc_html_e('Add New','contact-forms'); ?></a>
1612 -<hr class="wp-header-end">
1613 -<p><?php esc_html_e( 'Use the shortcode or block to include forms in posts, pages or other content types.', 'contact-forms'); ?></p>
981 +<h2><img src="<?php echo ACCUA_FORMS_DIR_URL.'img/cimatti-icon-20.png'; ?>"/> <?php _e( 'Contact Forms', 'contact-forms'); ?>
982 + <a class="add-new-h2" href="<?php echo get_admin_url(); ?>admin.php?page=accua_forms_add"><?php _e('Add New','contact-forms'); ?></a>
983 +</h2>
984 +<div ><?php
985 + echo strtr(__( 'Use the turquoise blue %img_c button in the TinyMCE editor to include the forms in posts, pages or other content types (shortcode and php functions also available)', 'contact-forms'),
986 + array('%img_c'=>'<img alt="C" src="' . plugins_url('img/cimatti-icon-16.png', ACCUA_FORMS_FILE ) . '" />')
987 + );
988 +?></div>
1614 989 <?php
1615 990 accua_forms_list_page_table();
1616 991 ?>
1617 992 </div>
@@ -1618,17 +993,11 @@
1618 993 <?php
1619 994 }
1620 995
1621 996 function accua_forms_edit_page($fid) {
1622 - global $wpdb;
997 + wp_enqueue_script('jquery-ui-tabs','','','',true);
998 + wp_enqueue_script('contact_forms_tabs', plugins_url('accua_tabs.js', ACCUA_FORMS_FILE ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION);
1623 999
1624 - // Initialize draft for this form (creates from published data if no draft exists)
1625 - _accua_forms_init_draft($fid);
1626 -
1627 - wp_enqueue_script('accua_tabs_component', plugins_url('assets/js/admin/accua-tabs.js', ACCUA_FORMS_FILE ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION, true );
1628 - wp_enqueue_script('contact_forms_tabs', plugins_url('assets/js/admin/tabs.js', ACCUA_FORMS_FILE ), array( 'jquery', 'accua_tabs_component' ), ACCUA_FORMS_JS_VERSION, true );
1629 - wp_enqueue_script('accua_verify_gads_conversion_code', plugins_url('assets/js/admin/verify-gads-conversion.js', ACCUA_FORMS_FILE ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION, true );
1630 -
1631 1000 if (!class_exists('AccuaFormsHelp')) {
1632 1001 require_once('accua-forms-help.php');
1633 1002 }
1634 1003 $accuaHelp = AccuaFormsHelp::getInstance();
@@ -1655,15 +1024,16 @@
1655 1024 );
1656 1025 */
1657 1026
1658 1027 $avail_fields = get_option('accua_forms_avail_fields', array());
1659 - $default_form_data = get_option('accua_forms_default_form_data', array()) + accua_forms_get_default_form_data();
1028 + $default_form_data = get_option('accua_forms_default_form_data',array());
1660 1029
1661 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only form restore flag, parent function checks nonce
1030 +
1031 +
1662 1032 $form_data = _accua_forms_get_form_data($fid, true, !empty($_GET['restore']));
1663 1033 $form_overrided_data = $form_data['_overrided'];
1664 1034
1665 - $fid_esc = esc_attr($fid);
1035 + $fid_esc = htmlspecialchars($fid, ENT_QUOTES);
1666 1036
1667 1037 $adminurl = admin_url();
1668 1038
1669 1039 global $wp_version;
@@ -1678,60 +1048,63 @@
1678 1048 }
1679 1049
1680 1050 ?>
1681 1051 <div id="accua_forms_edit_page" class="accua_forms_admin_page wrap">
1682 -<h1 class="wp-heading-inline"><?php esc_html_e( 'Contact Forms - Edit Form', 'contact-forms' ); ?></h1>
1683 -<?php
1684 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom table, lightweight count query
1685 - $submission_count = (int) $wpdb->get_var( $wpdb->prepare(
1686 - "SELECT COUNT(*) FROM `{$wpdb->prefix}accua_forms_submissions` WHERE afs_form_id = %s AND afs_status >= 0",
1687 - $fid
1688 - ) );
1689 - $submissions_url = admin_url( 'admin.php?page=accua_forms_submissions_list&fid=' . urlencode( $fid ) );
1690 - printf(
1691 - '<a class="page-title-action" href="%s">%s (%s)</a>',
1692 - esc_url( $submissions_url ),
1693 - esc_html__( 'Submissions', 'contact-forms' ),
1694 - esc_html( number_format_i18n( $submission_count ) )
1695 - );
1696 -?>
1697 -<hr class="wp-header-end">
1052 +<h2><img src="<?php echo ACCUA_FORMS_DIR_URL.'img/cimatti-icon-20.png'; ?>"/> <?php _e('Contact Forms - Edit Form', 'contact-forms'); ?></h2>
1053 +<div class="accua_form_save_settings_status"></div>
1698 1054 <?php wp_nonce_field('edit_form', '_nonce_edit_form'); ?>
1699 -<div id="titlediv">
1700 - <div id="titlewrap">
1701 - <input id="title" type="text" autocomplete="off" value="<?php echo esc_attr($form_data['title']) ?>" size="30" name="post_title" placeholder="<?php esc_attr_e( 'Enter title here', 'contact-forms' ); ?>">
1702 - </div>
1055 +<div id="titlediv"><br />
1056 + <label id="title-prompt-text" class="screen-reader-text" for="title"><?php _e( 'Enter title here', 'contact-forms'); ?></label>
1057 + <input id="title" type="text" autocomplete="off" value="<?php echo htmlspecialchars($form_data['title'], ENT_QUOTES) ?>" size="30" name="post_title">
1058 + <script type="text/javascript">
1059 + jQuery(function($){
1060 + if ( jQuery('#titlediv #title').val() == '' )
1061 + jQuery('#title-prompt-text').removeClass('screen-reader-text');
1062 +
1063 + jQuery('#titlediv #title').focus(function() {
1064 + jQuery('#title-prompt-text').addClass('screen-reader-text');
1065 + });
1066 + jQuery('#titlediv #title').blur(function() {
1067 + if ( jQuery('#titlediv #title').val() == '' )
1068 + jQuery('#title-prompt-text').removeClass('screen-reader-text');
1069 + });
1070 + });
1071 + </script>
1703 1072 </div>
1704 - <div id="accua_tabs" class="accua-tabs accua-tabs--primary" data-default-tab="fields">
1705 - <div class="accua-tabs__header">
1706 - <div class="accua-tabs__tablist" role="tablist" aria-label="<?php esc_attr_e( 'Form editor', 'contact-forms' ); ?>">
1707 - <button class="accua-tabs__tab" role="tab" data-tab="fields"><?php esc_html_e( 'Fields', 'contact-forms' ); ?></button>
1708 - <button class="accua-tabs__tab" role="tab" data-tab="customise"><?php esc_html_e( 'Appearance and General', 'contact-forms' ); ?></button>
1709 - <button class="accua-tabs__tab" role="tab" data-tab="messages"><?php esc_html_e( 'Messages', 'contact-forms' ); ?></button>
1710 - <button class="accua-tabs__tab" role="tab" data-tab="retention"><?php esc_html_e( 'Data Retention', 'contact-forms' ); ?></button>
1711 - <button class="accua-tabs__tab" role="tab" data-tab="google_ads">Google Ads</button>
1712 - <button class="accua-tabs__tab" role="tab" data-tab="tokens"><?php esc_html_e( 'Tokens', 'contact-forms' ); ?></button>
1713 - </div>
1714 - <div id="accua_tabs_actions" class="accua_tabs_actions">
1715 - <form id="delete_form" action="admin.php?page=accua_forms_list" method="POST" onsubmit="return confirm(<?php print esc_attr(_accua_forms_json_encode(__('Do you really want to delete this form?', 'contact-forms'))); ?>);">
1716 - <input type="hidden" name="accua-form-edit-action" value="delete" />
1717 - <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $fid_esc is pre-escaped with esc_attr() ?>
1718 - <input type="hidden" name="form-id" value="<?php echo $fid_esc; ?>" />
1719 - <input type="submit" value="<?php esc_attr_e( 'Delete this form', 'contact-forms' ); ?>" />
1720 - <?php wp_nonce_field( 'contact-forms-delete_'.$fid ); ?>
1721 - </form>
1722 - <input class="button button-primary button-large accua_form_save_settings_button" id="accua_form_save_settings_top" type="button" value="<?php echo esc_attr(__( 'Save', 'contact-forms')); ?>" />
1723 - <span class="accua_form_save_settings_status"></span>
1724 - </div>
1073 + <div id="accua_tabs">
1074 + <div id="save_settings_top" class="accua_forms_save_settings_top">
1075 + <form id="delete_form" action="admin.php?page=accua_forms_list" method="POST" onsubmit="return confirm(<?php print htmlspecialchars(_accua_forms_json_encode(__('Do you really want to delete this form?', 'contact-forms')), ENT_QUOTES); ?>);">
1076 + <input type="hidden" name="accua-form-edit-action" value="delete" />
1077 + <input type="hidden" name="form-id" value="<?php echo $fid_esc; ?>" />
1078 + <input type="submit" value="<?php _e( 'Delete this form', 'contact-forms'); ?>" />
1079 + <?php wp_nonce_field( 'contact-forms-delete_'.$fid ); ?>
1080 + </form>
1081 + <?php /*<input class="button button-primary button-large accua_form_save_settings_button" id="accua_form_save_settings" type="button" value="<?php echo htmlspecialchars(__( 'Save settings', 'contact-forms'), ENT_QUOTES); ?>" /> */ ?>
1725 1082 </div>
1726 - <div id="accua_tab_fields" class="accua-tabs__panel" role="tabpanel" data-tab="fields">
1083 + <ul id="ul_accua_tabs">
1084 + <li class="tabs"><a href="#accua_tab_fields"><?php _e( 'Fields', 'contact-forms'); ?></a></li>
1085 + <li class="tabs"><a href="#accua_tab_messages"><?php _e( 'Messages', 'contact-forms'); ?></a></li>
1086 + <?php /*<li class="tabs"><a href="#accua_tab_preview"><?php _e( 'Preview/Test', 'contact-forms'); ?></a></li> */ ?>
1087 + </ul>
1088 + <div id="accua_tab_fields" class="content_tab">
1089 + <div style="width:50%; float:left;background: #f4f4f4;">
1090 + <div style="padding: 20px;">
1091 + <input class="button button-primary button-large accua_form_save_settings_button" id="accua_form_save_settings_inside" type="button" value="<?php echo htmlspecialchars(__( 'Save', 'contact-forms'), ENT_QUOTES); ?>" />
1092 + <div id="accua_tabs2">
1093 + <ul>
1094 + <li class="tabs"><a href="#accua_tab_fields2"><?php _e( 'Fields', 'contact-forms'); ?></a></li>
1095 + <li class="tabs"><a href="#accua_tab_customise"><?php _e( 'Appearance', 'contact-forms'); ?></a></li>
1096 + </ul>
1097 + <div id="accua_tab_fields2">
1098 + <h2><?php _e( 'Drag & Drop Form Fields', 'contact-forms'); ?></h2>
1099 + <?php /*<a href="admin.php?page=accua_forms_fields" target="_blank"><strong><?php _e( 'Create new fields here', 'contact-forms'); ?></strong></a></p> */ ?>
1100 + <div style="width:30%; float:left;">
1727 1101 <!-- Begin available fields -->
1728 - <div class="widget-liquid-left">
1729 - <h2><?php esc_html_e( 'Available Fields', 'contact-forms' ); ?></h2>
1730 - <input type="text" id="accua-fields-filter" class="accua-fields-filter" placeholder="<?php esc_attr_e( 'Filter fields…', 'contact-forms' ); ?>" autocomplete="off" />
1731 - <div id="widgets-left">
1102 +
1103 + <div class="widget-liquid-left" style="margin-right:0">
1104 + <!-- <div id="widgets-left"> -->
1105 + <div id="widgets-left" style="margin-right:5px;">
1732 1106 <div id="available-widgets" class="widgets-holder-wrap">
1733 - <div class="accua-form-widget-scroll-wrapper">
1734 1107 <div class="widget-holder">
1735 1108 <div id="widget-list">
1736 1109 <!-- begin fields list -->
1737 1110
@@ -1749,9 +1122,9 @@
1749 1122 'name' => __('Fieldset begin', 'contact-forms'),
1750 1123 'type' => 'fieldset-begin',
1751 1124 'description' => '',
1752 1125 );
1753 - } elseif ($field['ref'] == '__fieldset-end') {
1126 + } else if ($field['ref'] == '__fieldset-end') {
1754 1127 $ref = array(
1755 1128 'id' => '__fieldset-end',
1756 1129 'name' => __('Fieldset end', 'contact-forms'),
1757 1130 'type' => 'fieldset-end',
@@ -1760,10 +1133,8 @@
1760 1133 }
1761 1134 }
1762 1135 } else {
1763 1136 $ref = $avail_fields[$field['ref']];
1764 - if ( ! isset( $ref['id'] ) ) { $ref['id'] = $field['ref']; }
1765 - if ( ! isset( $ref['name'] ) ) { $ref['name'] = $ref['label'] ?? $field['ref']; }
1766 1137 }
1767 1138
1768 1139 //print_r($ref);
1769 1140 $form_fields_html .= accua_forms_field_text_settings_form($fid, $ref, $field);
@@ -1769,20 +1140,15 @@
1769 1140 $form_fields_html .= accua_forms_field_text_settings_form($fid, $ref, $field);
1770 1141 }
1771 1142
1772 1143
1773 - foreach ($avail_fields as $avail_field_key => $avail_field) {
1774 - if ( ! isset( $avail_field['id'] ) ) { $avail_field['id'] = $avail_field_key; }
1775 - if ( ! isset( $avail_field['name'] ) ) { $avail_field['name'] = $avail_field['label'] ?? $avail_field_key; }
1144 + foreach ($avail_fields as $avail_field) {
1776 1145 $hidden = (empty($form_data['fields'][$avail_field['id']])) ? false : 'hidden';
1777 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is pre-escaped in heredoc templates
1778 1146 echo accua_forms_field_text_settings_form($fid, $avail_field, $hidden);
1779 1147 }
1780 - // Custom HTML field
1781 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is pre-escaped in heredoc templates
1148 + //Custom HTML field
1782 1149 echo accua_forms_field_text_settings_form($fid);
1783 - // Fieldset begin
1784 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is pre-escaped in heredoc templates
1150 + //Fieldset begin
1785 1151 echo accua_forms_field_text_settings_form($fid, array(
1786 1152 'id' => '__fieldset-begin',
1787 1153 'name' => __( 'Fieldset begin', 'contact-forms'),
1788 1154 'type' => 'fieldset-begin',
@@ -1789,10 +1155,9 @@
1789 1155 'description' => __('You can use this field multiple times.', 'contact-forms'),
1790 1156 'default_value' => '',
1791 1157 'allowed_values' => '',
1792 1158 ));
1793 - // Fieldset end
1794 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is pre-escaped in heredoc templates
1159 + //Fieldset end
1795 1160 echo accua_forms_field_text_settings_form($fid, array(
1796 1161 'id' => '__fieldset-end',
1797 1162 'name' => __( 'Fieldset end', 'contact-forms'),
1798 1163 'type' => 'fieldset-end',
@@ -1806,9 +1171,8 @@
1806 1171 </div>
1807 1172
1808 1173 <br class='clear' />
1809 1174 </div>
1810 - </div>
1811 1175 <br class="clear" />
1812 1176 </div>
1813 1177
1814 1178 </div>
@@ -1813,319 +1177,200 @@
1813 1177
1814 1178 </div>
1815 1179 </div>
1816 1180 <!-- End available fields -->
1181 + </div>
1817 1182
1818 - <div class="widget-liquid-right">
1819 - <div id="widgets-right">
1820 - <h2><?php esc_html_e( 'Drop fields here', 'contact-forms' ); ?></h2>
1183 + <div style="width:70%; float:left;" class="container">
1184 + <!--
1185 + <h3>Form Fields</h3>
1186 + <div id="form_fields_container">
1187 + </div>
1188 + -->
1189 +
1190 + <div class="widget-liquid-right" style="width:100%">
1191 + <div id="widgets-right" style="width:100%">
1821 1192 <div class="widgets-holder-wrap dashed">
1822 - <div class="accua-form-widget-scroll-wrapper">
1823 - <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $fid_esc is pre-escaped with esc_attr() ?>
1193 + <div class="sidebar-name">
1194 + <div class="sidebar-name-arrow"><br></div>
1195 + <h3><?php _e( 'Drop fields here', 'contact-forms'); ?> <span><img alt="" title="" class="ajax-feedback" src="<?php echo $adminurl;?>images/wpspin_light.gif"></span></h3>
1196 + </div>
1824 1197 <div class="widgets-sortables ui-sortable" id="cimatti-accua-fields-form-area-<?php echo $fid_esc ?>">
1825 - <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $form_fields_html is built from pre-escaped heredoc templates ?>
1826 1198 <?php echo $form_fields_html; ?>
1827 1199 </div>
1828 - </div>
1829 1200 </div>
1830 1201 </div>
1831 1202 </div>
1832 - </div><!-- /panel: fields -->
1833 - <div id="accua_tab_customise" class="accua-tabs__panel" role="tabpanel" data-tab="customise">
1834 - <div class="accua-customise-columns">
1835 - <div class="accua-style-column">
1836 - <h2><?php esc_html_e( 'General', 'contact-forms' ); ?></h2>
1837 - <p id="accua_form_use_ajax"><input id="accua_form_use_ajax_check" class="accua_form_value" type="checkbox" value="1" <?php if (!empty($form_data['use_ajax'])) {echo 'checked="checked" ';} ?>/><label for="accua_form_use_ajax_check"><?php esc_html_e( 'Do not reload the page on form submission', 'contact-forms' ); ?></label></p>
1838 1203
1839 - <p id="accua_form_layout"><?php esc_html_e( 'Labels', 'contact-forms' ); ?> <select name="layout" class="accua_form_value">
1840 - <option value="" <?php selected( ! isset( $form_overrided_data['layout'] ) ); ?>><?php printf( /* translators: %s: current default layout label */ esc_html__( 'default (%s)', 'contact-forms' ), esc_html( accua_forms_get_layout_label( $default_form_data['layout'] ) ) ); ?></option>
1841 - <option value="sidebyside" <?php selected( isset( $form_overrided_data['layout'] ) && 'sidebyside' === $form_data['layout'] ); ?>><?php echo esc_html( accua_forms_get_layout_label( 'sidebyside' ) ); ?></option>
1842 - <option value="toplabel" <?php selected( isset( $form_overrided_data['layout'] ) && 'toplabel' === $form_data['layout'] ); ?>><?php echo esc_html( accua_forms_get_layout_label( 'toplabel' ) ); ?></option>
1843 - <option value="inlinelabel" <?php selected( isset( $form_overrided_data['layout'] ) && 'inlinelabel' === $form_data['layout'] ); ?>><?php echo esc_html( accua_forms_get_layout_label( 'inlinelabel' ) ); ?></option>
1844 - </select></p>
1845 - <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>
1204 + </div>
1205 + </div>
1206 + <div id="accua_tab_customise">
1207 + <div style="width: 48%; float:left;">
1208 + <h3><?php _e( 'General', 'contact-forms'); ?></h3>
1209 + <p id="accua_form_use_ajax"><input class="accua_form_value" type="checkbox" value="1" <?php if (!empty($form_data['use_ajax'])) {echo 'checked="checked" ';} ?>/><?php _e('Do not reload the page on form submission', 'contact-forms'); ?></p>
1846 1210
1847 - <h2><?php esc_html_e( 'Form Container', 'contact-forms' ); ?></h2>
1211 + <p id="accua_form_layout"><?php _e( 'Labels', 'contact-forms'); ?> <select name="layout" class="accua_form_value">
1212 + <option value="" <?php if (isset($form_overrided_data['layout'])) { echo 'selected="selected"'; } ?>>default (<?php if($default_form_data['layout']=='sidebyside') _e( 'Labels on the left of the fields', 'contact-forms'); else _e( 'Labels on top of the fields', 'contact-forms'); ?>)</option><option value="sidebyside" <?php if ((isset($form_overrided_data['layout'])) && ($form_data['layout'] == 'sidebyside')) { echo 'selected="selected"'; } ?>><?php _e( 'Labels on the left of the fields', 'contact-forms'); ?></option><option value="toplabel" <?php if ((isset($form_overrided_data['layout'])) && ($form_data['layout'] == 'toplabel')) { echo 'selected="selected"'; } ?>><?php _e( 'Labels on top of the fields', 'contact-forms'); ?></option></select>
1213 + </p>
1848 1214
1849 - <div class="accua-style-row" id="accua_form_style_margin">
1850 - <div class="accua-style-toggle">
1851 - <input name="accua_form_style_margin" id="accua_form_style_margin_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_margin'])) {echo 'checked="checked" ';} ?>/>
1852 - </div>
1853 - <div class="accua-style-content">
1854 - <label class="accua-style-label" for="accua_form_style_margin_check">margin</label>
1855 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_margin']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_margin']); ?>" />
1856 - <span class="accua-style-help"><?php esc_html_e( 'Outer spacing around the form', 'contact-forms' ); ?></span>
1857 - </div>
1215 + <div id="accua_form_style_margin" class="label_input" class="label_container">
1216 + <input name="accua_form_style_margin" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_margin'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Margin', 'contact-forms'); ?></strong>
1217 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_margin']); ?></div>
1218 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_margin'], ENT_QUOTES) ?>" />
1219 +
1858 1220 </div>
1859 1221
1860 - <div class="accua-style-row" id="accua_form_style_padding">
1861 - <div class="accua-style-toggle">
1862 - <input name="accua_form_style_padding" id="accua_form_style_padding_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_padding'])) {echo 'checked="checked" ';} ?>/>
1863 - </div>
1864 - <div class="accua-style-content">
1865 - <label class="accua-style-label" for="accua_form_style_padding_check">padding</label>
1866 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_padding']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_padding']); ?>" />
1867 - <span class="accua-style-help"><?php esc_html_e( 'Inner spacing inside the form', 'contact-forms' ); ?></span>
1868 - </div>
1222 + <div class="label_input">
1223 + <div id="accua_form_style_border_color" class="label_container">
1224 + <input name="accua_form_style_border_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_color'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Border color', 'contact-forms'); ?></strong>
1225 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_border_color']); ?></div>
1226 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_color'], ENT_QUOTES) ?>" />
1227 + </div>
1228 + <div id="accua_form_style_border_width" class="label_container">
1229 + <input name="accua_form_style_border_width" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_width'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Width', 'contact-forms'); ?>
1230 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_border_width']); ?></div>
1231 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_width'], ENT_QUOTES) ?>" />
1232 + </div>
1233 + <div id="accua_form_style_border_radius" class="label_container">
1234 + <input name="accua_form_style_border_radius" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_radius'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Radius', 'contact-forms'); ?>
1235 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_border_radius']); ?></div>
1236 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_radius'], ENT_QUOTES) ?>" />
1237 + </div>
1869 1238 </div>
1870 1239
1871 - <div class="accua-style-row" id="accua_form_style_background_color">
1872 - <div class="accua-style-toggle">
1873 - <input name="accua_form_style_background_color" id="accua_form_style_background_color_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_background_color'])) {echo 'checked="checked" ';} ?>/>
1874 - </div>
1875 - <div class="accua-style-content">
1876 - <label class="accua-style-label" for="accua_form_style_background_color_check">background-color</label>
1877 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_background_color']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_background_color']); ?>" />
1878 - <span class="accua-style-help"><?php esc_html_e( 'Form background fill', 'contact-forms' ); ?></span>
1879 - </div>
1880 - </div>
1240 + <div class="label_input">
1241 + <div id="accua_form_style_background_color" class="label_container">
1242 + <input name="accua_form_style_background_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_background_color'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Background', 'contact-forms'); ?></strong>
1243 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_background_color']); ?></div>
1244 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_background_color'], ENT_QUOTES) ?>" />
1245 + </div>
1881 1246
1882 - <div class="accua-style-row" id="accua_form_style_border_color">
1883 - <div class="accua-style-toggle">
1884 - <input name="accua_form_style_border_color" id="accua_form_style_border_color_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_color'])) {echo 'checked="checked" ';} ?>/>
1885 - </div>
1886 - <div class="accua-style-content">
1887 - <label class="accua-style-label" for="accua_form_style_border_color_check">border-color</label>
1888 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_border_color']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_border_color']); ?>" />
1889 - <span class="accua-style-help"><?php esc_html_e( 'Form border color', 'contact-forms' ); ?></span>
1890 - </div>
1247 + <div id="accua_form_style_padding" class="label_container">
1248 + <input name="accua_form_style_padding" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_padding'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Padding', 'contact-forms'); ?></strong>
1249 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_padding']); ?></div>
1250 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_padding'], ENT_QUOTES) ?>" />
1251 + </div>
1891 1252 </div>
1253 + <div class="label_input">
1254 + <div id="accua_form_style_color" class="label_container">
1255 + <input name="accua_form_style_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_color'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Font', 'contact-forms'); ?></strong>
1256 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_color']); ?></div>
1257 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_color'], ENT_QUOTES) ?>" />
1258 + </div>
1892 1259
1893 - <div class="accua-style-row" id="accua_form_style_border_width">
1894 - <div class="accua-style-toggle">
1895 - <input name="accua_form_style_border_width" id="accua_form_style_border_width_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_width'])) {echo 'checked="checked" ';} ?>/>
1896 - </div>
1897 - <div class="accua-style-content">
1898 - <label class="accua-style-label" for="accua_form_style_border_width_check">border-width</label>
1899 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_border_width']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_border_width']); ?>" />
1900 - <span class="accua-style-help"><?php esc_html_e( 'Form border thickness', 'contact-forms' ); ?></span>
1901 - </div>
1260 + <div id="accua_form_style_font_size" class="label_container">
1261 + <input name="accua_form_style_font_size" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_font_size'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Size', 'contact-forms'); ?>
1262 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_font_size']); ?></div>
1263 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_font_size'], ENT_QUOTES) ?>" />
1264 + </div>
1902 1265 </div>
1903 -
1904 - <div class="accua-style-row" id="accua_form_style_border_radius">
1905 - <div class="accua-style-toggle">
1906 - <input name="accua_form_style_border_radius" id="accua_form_style_border_radius_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_radius'])) {echo 'checked="checked" ';} ?>/>
1907 - </div>
1908 - <div class="accua-style-content">
1909 - <label class="accua-style-label" for="accua_form_style_border_radius_check">border-radius</label>
1910 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_border_radius']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_border_radius']); ?>" />
1911 - <span class="accua-style-help"><?php esc_html_e( 'Rounded corners', 'contact-forms' ); ?></span>
1912 - </div>
1913 1266 </div>
1267 + <div style="width: 48%; float:left;">
1914 1268
1915 - <div class="accua-style-row" id="accua_form_style_color">
1916 - <div class="accua-style-toggle">
1917 - <input name="accua_form_style_color" id="accua_form_style_color_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_color'])) {echo 'checked="checked" ';} ?>/>
1918 - </div>
1919 - <div class="accua-style-content">
1920 - <label class="accua-style-label" for="accua_form_style_color_check">color</label>
1921 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_color']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_color']); ?>" />
1922 - <span class="accua-style-help"><?php esc_html_e( 'Form text color', 'contact-forms' ); ?></span>
1923 - </div>
1924 - </div>
1269 + <h3><?php _e( 'Fields', 'contact-forms'); ?></h3>
1925 1270
1926 - <div class="accua-style-row" id="accua_form_style_font_size">
1927 - <div class="accua-style-toggle">
1928 - <input name="accua_form_style_font_size" id="accua_form_style_font_size_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_font_size'])) {echo 'checked="checked" ';} ?>/>
1929 - </div>
1930 - <div class="accua-style-content">
1931 - <label class="accua-style-label" for="accua_form_style_font_size_check">font-size</label>
1932 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_font_size']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_font_size']); ?>" />
1933 - <span class="accua-style-help"><?php esc_html_e( 'Base text size', 'contact-forms' ); ?></span>
1934 - </div>
1271 + <div id="accua_form_style_field_spacing" class="label_input">
1272 + <input name="accua_form_style_field_spacing" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_spacing'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Spacing', 'contact-forms'); ?>
1273 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_spacing']); ?></div>
1274 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_spacing'], ENT_QUOTES) ?>" />
1935 1275 </div>
1936 1276
1937 - </div>
1938 - <div class="accua-style-column">
1939 -
1940 - <h2><?php esc_html_e( 'Input Fields', 'contact-forms' ); ?></h2>
1941 -
1942 - <div class="accua-style-row" id="accua_form_style_field_spacing">
1943 - <div class="accua-style-toggle">
1944 - <input name="accua_form_style_field_spacing" id="accua_form_style_field_spacing_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_spacing'])) {echo 'checked="checked" ';} ?>/>
1945 - </div>
1946 - <div class="accua-style-content">
1947 - <label class="accua-style-label" for="accua_form_style_field_spacing_check">margin-bottom</label>
1948 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_field_spacing']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_field_spacing']); ?>" />
1949 - <span class="accua-style-help"><?php esc_html_e( 'Space between fields', 'contact-forms' ); ?></span>
1950 - </div>
1277 + <div id="accua_form_style_field_border_color" class="label_input">
1278 + <input name="accua_form_style_field_border_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Border color', 'contact-forms'); ?>
1279 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_border_color']); ?></div>
1280 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_color'], ENT_QUOTES) ?>" />
1951 1281 </div>
1952 1282
1953 - <div class="accua-style-row" id="accua_form_style_field_padding">
1954 - <div class="accua-style-toggle">
1955 - <input name="accua_form_style_field_padding" id="accua_form_style_field_padding_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_padding'])) {echo 'checked="checked" ';} ?>/>
1956 - </div>
1957 - <div class="accua-style-content">
1958 - <label class="accua-style-label" for="accua_form_style_field_padding_check">padding</label>
1959 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_field_padding']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_field_padding']); ?>" />
1960 - <span class="accua-style-help"><?php esc_html_e( 'Inner spacing in inputs', 'contact-forms' ); ?></span>
1961 - </div>
1283 + <div id="accua_form_style_field_border_width" class="label_input">
1284 + <input name="accua_form_style_field_border_width" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_width'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Border width', 'contact-forms'); ?>
1285 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_border_width']); ?></div>
1286 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_width'], ENT_QUOTES) ?>" />
1962 1287 </div>
1963 1288
1964 - <div class="accua-style-row" id="accua_form_style_field_background_color">
1965 - <div class="accua-style-toggle">
1966 - <input name="accua_form_style_field_background_color" id="accua_form_style_field_background_color_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_background_color'])) {echo 'checked="checked" ';} ?>/>
1967 - </div>
1968 - <div class="accua-style-content">
1969 - <label class="accua-style-label" for="accua_form_style_field_background_color_check">background-color</label>
1970 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_field_background_color']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_field_background_color']); ?>" />
1971 - <span class="accua-style-help"><?php esc_html_e( 'Input field fill color', 'contact-forms' ); ?></span>
1972 - </div>
1289 + <div id="accua_form_style_field_border_radius" class="label_input">
1290 + <input name="accua_form_style_field_border_radius" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_radius'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Rounded corner radius', 'contact-forms'); ?>
1291 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_border_radius']); ?></div>
1292 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_radius'], ENT_QUOTES) ?>" />
1973 1293 </div>
1974 1294
1975 - <div class="accua-style-row" id="accua_form_style_field_border_color">
1976 - <div class="accua-style-toggle">
1977 - <input name="accua_form_style_field_border_color" id="accua_form_style_field_border_color_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_color'])) {echo 'checked="checked" ';} ?>/>
1978 - </div>
1979 - <div class="accua-style-content">
1980 - <label class="accua-style-label" for="accua_form_style_field_border_color_check">border-color</label>
1981 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_field_border_color']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_field_border_color']); ?>" />
1982 - <span class="accua-style-help"><?php esc_html_e( 'Input border color', 'contact-forms' ); ?></span>
1983 - </div>
1295 + <div id="accua_form_style_field_background_color" class="label_input">
1296 + <input name="accua_form_style_field_background_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_background_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Background color', 'contact-forms'); ?>
1297 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_background_color']); ?></div>
1298 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_background_color'], ENT_QUOTES) ?>" />
1984 1299 </div>
1985 1300
1986 - <div class="accua-style-row" id="accua_form_style_field_border_width">
1987 - <div class="accua-style-toggle">
1988 - <input name="accua_form_style_field_border_width" id="accua_form_style_field_border_width_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_width'])) {echo 'checked="checked" ';} ?>/>
1989 - </div>
1990 - <div class="accua-style-content">
1991 - <label class="accua-style-label" for="accua_form_style_field_border_width_check">border-width</label>
1992 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_field_border_width']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_field_border_width']); ?>" />
1993 - <span class="accua-style-help"><?php esc_html_e( 'Input border thickness', 'contact-forms' ); ?></span>
1994 - </div>
1301 + <div id="accua_form_style_field_padding" class="label_input">
1302 + <input name="accua_form_style_field_padding" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_padding'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Padding', 'contact-forms'); ?>
1303 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_padding']); ?></div>
1304 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_padding'], ENT_QUOTES) ?>" />
1995 1305 </div>
1996 1306
1997 - <div class="accua-style-row" id="accua_form_style_field_border_radius">
1998 - <div class="accua-style-toggle">
1999 - <input name="accua_form_style_field_border_radius" id="accua_form_style_field_border_radius_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_radius'])) {echo 'checked="checked" ';} ?>/>
2000 - </div>
2001 - <div class="accua-style-content">
2002 - <label class="accua-style-label" for="accua_form_style_field_border_radius_check">border-radius</label>
2003 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_field_border_radius']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_field_border_radius']); ?>" />
2004 - <span class="accua-style-help"><?php esc_html_e( 'Input rounded corners', 'contact-forms' ); ?></span>
2005 - </div>
1307 + <div id="accua_form_style_field_color" class="label_input">
1308 + <input name="accua_form_style_field_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Text color', 'contact-forms'); ?>
1309 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_color']); ?></div>
1310 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_color'], ENT_QUOTES) ?>" />
2006 1311 </div>
2007 1312
2008 - <div class="accua-style-row" id="accua_form_style_field_color">
2009 - <div class="accua-style-toggle">
2010 - <input name="accua_form_style_field_color" id="accua_form_style_field_color_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_color'])) {echo 'checked="checked" ';} ?>/>
2011 - </div>
2012 - <div class="accua-style-content">
2013 - <label class="accua-style-label" for="accua_form_style_field_color_check">color</label>
2014 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_field_color']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_field_color']); ?>" />
2015 - <span class="accua-style-help"><?php esc_html_e( 'Input text color', 'contact-forms' ); ?></span>
2016 - </div>
2017 - </div>
2018 1313
2019 - <h2><?php esc_html_e( 'Submit Button', 'contact-forms' ); ?></h2>
1314 + <h3><?php _e( 'Submit button', 'contact-forms'); ?></h3>
2020 1315
2021 - <div class="accua-style-row" id="accua_form_style_submit_padding">
2022 - <div class="accua-style-toggle">
2023 - <input name="accua_form_style_submit_padding" id="accua_form_style_submit_padding_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_padding'])) {echo 'checked="checked" ';} ?>/>
2024 - </div>
2025 - <div class="accua-style-content">
2026 - <label class="accua-style-label" for="accua_form_style_submit_padding_check">padding</label>
2027 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_submit_padding']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_submit_padding']); ?>" />
2028 - <span class="accua-style-help"><?php esc_html_e( 'Button inner spacing', 'contact-forms' ); ?></span>
2029 - </div>
1316 + <div id="accua_form_style_submit_border_color" class="label_input">
1317 + <input name="accua_form_style_submit_border_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Border color', 'contact-forms'); ?>
1318 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_border_color']); ?></div>
1319 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_color'], ENT_QUOTES) ?>" />
1320 + <?php _e( 'Customize', 'contact-forms'); ?>
2030 1321 </div>
2031 1322
2032 - <div class="accua-style-row" id="accua_form_style_submit_background_color">
2033 - <div class="accua-style-toggle">
2034 - <input name="accua_form_style_submit_background_color" id="accua_form_style_submit_background_color_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_background_color'])) {echo 'checked="checked" ';} ?>/>
2035 - </div>
2036 - <div class="accua-style-content">
2037 - <label class="accua-style-label" for="accua_form_style_submit_background_color_check">background-color</label>
2038 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_submit_background_color']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_submit_background_color']); ?>" />
2039 - <span class="accua-style-help"><?php esc_html_e( 'Button fill color', 'contact-forms' ); ?></span>
2040 - </div>
1323 + <div id="accua_form_style_submit_border_width" class="label_input">
1324 + <input name="accua_form_style_submit_border_width" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_width'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Border width', 'contact-forms'); ?>
1325 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_border_width']); ?></div>
1326 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_width'], ENT_QUOTES) ?>" />
2041 1327 </div>
2042 1328
2043 - <div class="accua-style-row" id="accua_form_style_submit_color">
2044 - <div class="accua-style-toggle">
2045 - <input name="accua_form_style_submit_color" id="accua_form_style_submit_color_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_color'])) {echo 'checked="checked" ';} ?>/>
2046 - </div>
2047 - <div class="accua-style-content">
2048 - <label class="accua-style-label" for="accua_form_style_submit_color_check">color</label>
2049 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_submit_color']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_submit_color']); ?>" />
2050 - <span class="accua-style-help"><?php esc_html_e( 'Button text color', 'contact-forms' ); ?></span>
2051 - </div>
1329 + <div id="accua_form_style_submit_border_radius" class="label_input">
1330 + <input name="accua_form_style_submit_border_radius" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_radius'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Rounded corner radius', 'contact-forms'); ?>
1331 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_border_radius']); ?></div>
1332 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_radius'], ENT_QUOTES) ?>" />
2052 1333 </div>
2053 1334
2054 - <div class="accua-style-row" id="accua_form_style_submit_font_size">
2055 - <div class="accua-style-toggle">
2056 - <input name="accua_form_style_submit_font_size" id="accua_form_style_submit_font_size_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_font_size'])) {echo 'checked="checked" ';} ?>/>
2057 - </div>
2058 - <div class="accua-style-content">
2059 - <label class="accua-style-label" for="accua_form_style_submit_font_size_check">font-size</label>
2060 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_submit_font_size']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_submit_font_size']); ?>" />
2061 - <span class="accua-style-help"><?php esc_html_e( 'Button text size', 'contact-forms' ); ?></span>
2062 - </div>
1335 + <div id="accua_form_style_submit_background_color" class="label_input">
1336 + <input name="accua_form_style_submit_background_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_background_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Background color', 'contact-forms'); ?>
1337 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_background_color']); ?></div>
1338 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_background_color'], ENT_QUOTES) ?>" />
2063 1339 </div>
2064 1340
2065 - <div class="accua-style-row" id="accua_form_style_submit_border_color">
2066 - <div class="accua-style-toggle">
2067 - <input name="accua_form_style_submit_border_color" id="accua_form_style_submit_border_color_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_color'])) {echo 'checked="checked" ';} ?>/>
2068 - </div>
2069 - <div class="accua-style-content">
2070 - <label class="accua-style-label" for="accua_form_style_submit_border_color_check">border-color</label>
2071 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_submit_border_color']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_submit_border_color']); ?>" />
2072 - <span class="accua-style-help"><?php esc_html_e( 'Button border color', 'contact-forms' ); ?></span>
2073 - </div>
1341 + <div id="accua_form_style_submit_padding" class="label_input">
1342 + <input name="accua_form_style_submit_padding" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_padding'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Padding', 'contact-forms'); ?>
1343 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_padding']); ?></div>
1344 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_padding'], ENT_QUOTES) ?>" />
2074 1345 </div>
2075 1346
2076 - <div class="accua-style-row" id="accua_form_style_submit_border_width">
2077 - <div class="accua-style-toggle">
2078 - <input name="accua_form_style_submit_border_width" id="accua_form_style_submit_border_width_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_width'])) {echo 'checked="checked" ';} ?>/>
2079 - </div>
2080 - <div class="accua-style-content">
2081 - <label class="accua-style-label" for="accua_form_style_submit_border_width_check">border-width</label>
2082 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_submit_border_width']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_submit_border_width']); ?>" />
2083 - <span class="accua-style-help"><?php esc_html_e( 'Button border thickness', 'contact-forms' ); ?></span>
2084 - </div>
1347 + <div id="accua_form_style_submit_color" class="label_input">
1348 + <input name="accua_form_style_submit_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Text color', 'contact-forms'); ?>
1349 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_color']); ?></div>
1350 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_color'], ENT_QUOTES) ?>" />
2085 1351 </div>
2086 1352
2087 - <div class="accua-style-row" id="accua_form_style_submit_border_radius">
2088 - <div class="accua-style-toggle">
2089 - <input name="accua_form_style_submit_border_radius" id="accua_form_style_submit_border_radius_check" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_radius'])) {echo 'checked="checked" ';} ?>/>
2090 - </div>
2091 - <div class="accua-style-content">
2092 - <label class="accua-style-label" for="accua_form_style_submit_border_radius_check">border-radius</label>
2093 - <input class="accua_form_value" type="text" value="<?php echo esc_attr($form_data['style_submit_border_radius']) ?>" placeholder="<?php echo esc_attr($default_form_data['style_submit_border_radius']); ?>" />
2094 - <span class="accua-style-help"><?php esc_html_e( 'Button rounded corners', 'contact-forms' ); ?></span>
2095 - </div>
1353 + <div id="accua_form_style_submit_font_size" class="label_input">
1354 + <input name="accua_form_style_submit_font_size" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_font_size'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Font size', 'contact-forms'); ?>
1355 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_font_size']); ?></div>
1356 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_font_size'], ENT_QUOTES) ?>" />
2096 1357 </div>
2097 1358
1359 + <br clear="all"/>
2098 1360 </div>
2099 - </div>
2100 - </div><!-- /panel: customise -->
2101 - <div id="accua_tab_google_ads" class="accua-tabs__panel" role="tabpanel" data-tab="google_ads">
2102 - <div class="postbox">
2103 - <div class="postbox-header"><h2>Google Ads Conversion Tracking</h2></div>
2104 - <div class="inside">
2105 - <table class="form-table" role="presentation">
2106 - <tr>
2107 - <th scope="row"><label for="gads_conversion_code_input"><?php esc_html_e( 'GADS Conversion Code', 'contact-forms' ); ?></label></th>
2108 - <td>
2109 - <input type="text"
2110 - id="gads_conversion_code_input"
2111 - name="gads_conversion_tracking_code"
2112 - class="accua_form_value regular-text"
2113 - value="<?php echo esc_attr($form_data['gads_conversion_tracking_code'] ?? ''); ?>"
2114 - pattern="AW-\d+/[a-zA-Z0-9]+"
2115 - title="(es: AW-123456789/aaBBccDD)"
2116 - />
2117 - <span id="gads_code_validation_message" class="validation-message" style="display:none; color:#d63638;"></span>
2118 - <p class="description"><?php esc_html_e( 'If you want to use Google Ads Conversion Tracking Code, please enter it here.', 'contact-forms' ); ?> (es: AW-123456789/aaBBccDD)</p>
2119 - </td>
2120 - </tr>
2121 - </table>
2122 - </div>
2123 - </div>
2124 - </div><!-- /panel: google_ads -->
1361 + </div>
1362 + </div>
2125 1363
2126 - <div id="accua_form_preview_pane" class="accua-form-preview-pane">
2127 - <h2><?php esc_html_e( 'Preview', 'contact-forms' ); ?></h2>
1364 +
1365 +
1366 + </div>
1367 + </div>
1368 + <div style="width:50%; float:right;">
1369 + <div style="padding: 15px;">
1370 + <h2><?php _e('Preview', 'contact-forms'); ?>
1371 + <?php echo $accuaHelp->add_pointer('form_edit_preview'); ?>
1372 + </h2>
2128 1373 <div id="accua_form_preview_area_wrapper">
2129 1374 <?php
2130 1375 echo "<script>
2131 1376 function resizeIframe(obj) {
@@ -2132,246 +1377,164 @@
2132 1377 altezza = obj.contentWindow.document.documentElement.scrollHeight + 200;
2133 1378 obj.style.height = altezza + 'px';
2134 1379 }
2135 1380 </script>";
1381 +
2136 1382 ?>
2137 - <iframe id="accua_form_preview_area" src="admin-ajax.php?action=accua_forms_preview&fid=<?php echo esc_attr($fid);?>&_wpnonce=<?php echo esc_attr( wp_create_nonce('accua_forms_preview') ); ?>" frameborder="0" scrolling="no" onload="resizeIframe(this)" ></iframe>
1383 + <iframe id="accua_form_preview_area" src="admin-ajax.php?action=accua_forms_preview&fid=<?php echo htmlspecialchars($fid,ENT_QUOTES);?>" frameborder="0" scrolling="no" onload="resizeIframe(this)" ></iframe>
1384 + <?php //todo: posso usare lo stile del sito? font ecc ?>
2138 1385 </div>
1386 +
1387 + </div>
2139 1388 </div>
2140 1389
2141 - <div id="accua_tab_messages" class="accua-tabs__panel" role="tabpanel" data-tab="messages">
1390 + <div style="clear:both;">&nbsp;</div>
1391 +
1392 + <?php /* * / ?>
1393 + <pre>
1394 + accua_forms_form_fields_order_post: <?php echo htmlspecialchars(print_r(get_option('accua_forms_form_fields_order_post'), true)); ?>
1395 +
1396 + accua_forms_save_form_field_post: <?php echo htmlspecialchars(print_r(get_option('accua_forms_save_form_field_post'), true)); ?>
1397 +
1398 + accua_forms_saved_form_data: <?php echo htmlspecialchars(print_r($form_data, true)); ?>
1399 +
1400 + </pre>
1401 + <?php /* */ ?>
1402 +</div>
1403 + <div id="accua_tab_messages" class="content_tab">
2142 1404 <?php
2143 - $email_font_formats =
2144 - 'Arial=arial,helvetica,sans-serif;'
2145 - . 'Arial Black=arial black,avant garde,sans-serif;'
2146 - . 'Comic Sans MS=comic sans ms,sans-serif;'
2147 - . 'Courier New=courier new,courier,monospace;'
2148 - . 'Georgia=georgia,palatino,serif;'
2149 - . 'Lucida Sans=lucida sans unicode,lucida grande,sans-serif;'
2150 - . 'Tahoma=tahoma,arial,helvetica,sans-serif;'
2151 - . 'Times New Roman=times new roman,times,serif;'
2152 - . 'Trebuchet MS=trebuchet ms,geneva,sans-serif;'
2153 - . 'Verdana=verdana,geneva,sans-serif;';
2154 -
2155 1405 $settings_editor = array(
2156 1406 'teeny' => true,
2157 1407 'editor_class' => 'accua_form_value',
2158 1408 'tinymce' => array(
2159 - 'toolbar1' => 'fontselect,|,bold,italic,underline,|,bullist,numlist,|,link,unlink',
2160 - 'font_formats' => $email_font_formats,
2161 - 'content_style' => 'body { font-family: arial, helvetica, sans-serif; }',
2162 - ));
1409 + 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,'));
2163 1410 ?>
2164 - <div class="accua-settings-grid">
2165 - <div class="postbox">
2166 - <div class="postbox-header"><h2><?php esc_html_e('1. On-screen success message', 'contact-forms'); ?></h2></div>
2167 - <div class="inside">
1411 +
1412 + <div class="metabox-holder accua-forms-metabox-holder">
1413 + <div class="postbox ">
1414 + <h3 class="hndle"><span><?php _e('1. On-screen success message', 'contact-forms'); ?></span></h3>
1415 + <div class="inside" id="dashboard_right_now">
2168 1416 <div id="accua_form_success_message">
2169 - <fieldset class="accua-radio-group">
2170 - <label><input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="0" <?php if (!isset($form_overrided_data['success_message'])) {echo ' checked ';} ?>> <?php esc_html_e( 'Use the default message', 'contact-forms' ); ?></label>
2171 - <label><input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="1" <?php if (isset($form_overrided_data['success_message']) && !isset($form_overrided_data['success_message_no_message'])) {echo ' checked ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2172 - <label><input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="-1" <?php if (isset($form_overrided_data['success_message_no_message'])) {echo ' checked ';} ?>/> <?php esc_html_e( 'Don\'t show any messages', 'contact-forms' ); ?></label>
2173 - </fieldset>
1417 + <input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="0" <?php if (!isset($form_overrided_data['success_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'contact-forms'); ?>
1418 + <input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="1" <?php if (isset($form_overrided_data['success_message']) && !isset($form_overrided_data['success_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'contact-forms'); ?>
1419 + <input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="-1" <?php if (isset($form_overrided_data['success_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'contact-forms'); ?><br />
2174 1420 <div class="defalut_message">
2175 - <?php esc_html_e( 'Default Success message', 'contact-forms' ); ?>
2176 - <div class="defalut_content_message"><?php echo wp_kses_post( wpautop( $default_form_data['success_message'] ) ); ?></div>
1421 + <?php _e( 'Default Success message', 'contact-forms'); ?>
1422 + <div class="defalut_content_message"><?php echo wpautop($default_form_data['success_message']); ?></div>
2177 1423 </div>
2178 1424 <?php wp_editor( $form_data['success_message'] , 'accua_form_success_message_textarea' , $settings_editor); ?>
1425 + <!-- <textarea class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['success_message'], ENT_QUOTES) ?></textarea> -->
2179 1426 </div>
2180 - </div>
1427 + </div>
1428 + </div>
2181 1429 </div>
2182 1430
2183 - <div class="postbox">
2184 - <div class="postbox-header"><h2><?php esc_html_e('2. On-screen error message', 'contact-forms'); ?></h2></div>
2185 - <div class="inside">
1431 + <div class="metabox-holder accua-forms-metabox-holder">
1432 + <div class="postbox ">
1433 + <h3 class="hndle"><span><?php _e('2. On-screen error message', 'contact-forms'); ?></span></h3>
1434 + <div class="inside" id="dashboard_right_now">
2186 1435 <div id="accua_form_error_message">
2187 - <fieldset class="accua-radio-group">
2188 - <label><input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="0" <?php if (!isset($form_overrided_data['error_message'])) {echo ' checked ';} ?>> <?php esc_html_e( 'Use the default message', 'contact-forms' ); ?></label>
2189 - <label><input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="1" <?php if (isset($form_overrided_data['error_message']) && !isset($form_overrided_data['error_message_no_message'])) {echo ' checked ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2190 - <label><input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="-1" <?php if (isset($form_overrided_data['error_message_no_message'])) {echo ' checked ';} ?>/> <?php esc_html_e( 'Don\'t show any messages', 'contact-forms' ); ?></label>
2191 - </fieldset>
1436 + <input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="0" <?php if (!isset($form_overrided_data['error_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'contact-forms'); ?>
1437 + <input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="1" <?php if (isset($form_overrided_data['error_message']) && !isset($form_overrided_data['error_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'contact-forms'); ?>
1438 + <input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="-1" <?php if (isset($form_overrided_data['error_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'contact-forms'); ?><br />
2192 1439 <div class="defalut_message">
2193 - <?php esc_html_e( 'Default error message', 'contact-forms' ); ?> <br />
2194 - <div class="defalut_content_message" ><?php echo wp_kses_post( wpautop( $default_form_data['error_message'] ) ); ?></div>
1440 + <?php _e( 'Default error message', 'contact-forms'); ?> <br />
1441 + <div class="defalut_content_message" ><?php echo wpautop($default_form_data['error_message']); ?></div>
2195 1442 </div>
2196 1443 <?php wp_editor( $form_data['error_message'] , 'accua_form_error_message_textarea' , $settings_editor); ?>
2197 1444 </div>
2198 1445 </div>
1446 + </div>
2199 1447 </div>
1448 + <br clear="all"/>
1449 + <div class="metabox-holder accua-forms-metabox-holder">
1450 + <div class="postbox ">
1451 + <h3 class="hndle"><span><?php _e('3. Email to notify administrator', 'contact-forms'); ?></span></h3>
1452 + <div class="inside" id="dashboard_right_now">
1453 + <div id="accua_form_admin_emails_to" class="label_input">
1454 + <label><?php _e('To', 'contact-forms'); ?></label>
1455 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['admin_emails_to']); ?></div>
1456 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_to'], ENT_QUOTES) ?>" />
1457 + <input name="accua_form_admin_emails_to" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['admin_emails_to'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?>
1458 + </div>
1459 + <div id="accua_form_emails_bcc" class="label_input">
1460 + <label><?php _e('Bcc', 'contact-forms'); ?></label>
1461 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['emails_bcc']); ?></div>
1462 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_bcc'], ENT_QUOTES) ?>" />
1463 + <input name ="accua_form_emails_bcc" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_bcc'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?>
1464 + </div>
2200 1465
2201 - <div class="postbox">
2202 - <div class="postbox-header"><h2><?php esc_html_e('3. Email to notify administrator', 'contact-forms'); ?></h2></div>
2203 - <div class="inside">
2204 - <table class="form-table" role="presentation">
2205 - <tr>
2206 - <th scope="row"><label><?php esc_html_e( 'To', 'contact-forms' ); ?></label></th>
2207 - <td id="accua_form_admin_emails_to">
2208 - <input class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['admin_emails_to']) ?>" <?php if (!isset($form_overrided_data['admin_emails_to'])) echo 'disabled'; ?> />
2209 - <label><input name="accua_form_admin_emails_to" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['admin_emails_to'])) {echo 'checked="checked" ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2210 - <p class="description"><?php printf( esc_html__( 'Default: %s', 'contact-forms' ), '<code>' . esc_html($default_form_data['admin_emails_to']) . '</code>' ); ?></p>
2211 - </td>
2212 - </tr>
2213 - <tr>
2214 - <th scope="row"><label><?php esc_html_e( 'Bcc', 'contact-forms' ); ?></label></th>
2215 - <td id="accua_form_emails_bcc">
2216 - <input class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['emails_bcc']) ?>" <?php if (!isset($form_overrided_data['emails_bcc'])) echo 'disabled'; ?> />
2217 - <label><input name="accua_form_emails_bcc" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_bcc'])) {echo 'checked="checked" ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2218 - <?php if ( ! empty( $default_form_data['emails_bcc'] ) ) { ?>
2219 - <p class="description"><?php printf( esc_html__( 'Default: %s', 'contact-forms' ), '<code>' . esc_html($default_form_data['emails_bcc']) . '</code>' ); ?></p>
2220 - <?php } ?>
2221 - </td>
2222 - </tr>
2223 - <tr>
2224 - <th scope="row"><label><?php esc_html_e( 'Subject', 'contact-forms'); ?></label></th>
2225 - <td id="accua_form_admin_emails_subject">
2226 - <input class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['admin_emails_subject']) ?>" <?php if (!isset($form_overrided_data['admin_emails_subject'])) echo 'disabled'; ?> />
2227 - <label><input name="accua_form_admin_emails_subject" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['admin_emails_subject'])) {echo 'checked="checked" ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2228 - <p class="description"><?php printf( esc_html__( 'Default: %s', 'contact-forms' ), '<code>' . esc_html($default_form_data['admin_emails_subject']) . '</code>' ); ?></p>
2229 - </td>
2230 - </tr>
2231 - </table>
1466 + <div id="accua_form_admin_emails_subject" class="label_input">
1467 + <label><?php _e( 'Subject', 'contact-forms'); ?></label>
1468 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['admin_emails_subject']); ?></div>
1469 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_subject'], ENT_QUOTES) ?>" />
1470 + <input name="accua_form_admin_emails_subject" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['admin_emails_subject'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?>
1471 + </div>
2232 1472
2233 1473 <div id="accua_form_admin_emails_message">
2234 - <fieldset class="accua-radio-group">
2235 - <label><input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="0" <?php if (!isset($form_overrided_data['admin_emails_message'])) {echo ' checked ';} ?>> <?php esc_html_e( 'Use the default message', 'contact-forms' ); ?></label>
2236 - <label><input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="1" <?php if (isset($form_overrided_data['admin_emails_message']) && !isset($form_overrided_data['admin_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2237 - <label><input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="-1" <?php if (isset($form_overrided_data['admin_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php esc_html_e( 'Don\'t show any messages', 'contact-forms' ); ?></label>
2238 - </fieldset>
1474 + <input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="0" <?php if (!isset($form_overrided_data['admin_emails_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'contact-forms'); ?>
1475 + <input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="1" <?php if (isset($form_overrided_data['admin_emails_message']) && !isset($form_overrided_data['admin_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'contact-forms'); ?>
1476 + <input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="-1" <?php if (isset($form_overrided_data['admin_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'contact-forms'); ?><br />
2239 1477 <div class="defalut_message">
2240 - <?php esc_html_e( 'Default message', 'contact-forms' ); ?>
2241 - <div class="defalut_content_message"><?php echo wp_kses_post( wpautop( $default_form_data['admin_emails_message'] ) ); ?></div>
1478 + <?php _e( 'Default message', 'contact-forms'); ?>
1479 + <div class="defalut_content_message"><?php echo wpautop($default_form_data['admin_emails_message']); ?></div>
2242 1480 </div>
2243 1481 <?php wp_editor( $form_data['admin_emails_message'] , 'accua_form_admin_emails_message_textarea' , $settings_editor); ?>
2244 1482 </div>
2245 1483
1484 + </div>
2246 1485 </div>
2247 1486 </div>
2248 1487
2249 - <div class="postbox">
2250 - <div class="postbox-header"><h2><?php esc_html_e('4. Email confirmation to the person who completed the form', 'contact-forms'); ?></h2></div>
2251 - <div class="inside">
2252 - <table class="form-table" role="presentation">
2253 - <tr>
2254 - <th scope="row"><label><?php esc_html_e( 'From name', 'contact-forms'); ?></label></th>
2255 - <td id="accua_form_emails_from_name">
2256 - <input class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['emails_from_name']) ?>" <?php if (!isset($form_overrided_data['emails_from_name'])) echo 'disabled'; ?> />
2257 - <label><input name="accua_form_emails_from_name" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_from_name'])) {echo 'checked="checked" ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2258 - <p class="description"><?php printf( esc_html__( 'Default: %s', 'contact-forms' ), '<code>' . esc_html($default_form_data['emails_from_name']) . '</code>' ); ?></p>
2259 - </td>
2260 - </tr>
2261 - <tr>
2262 - <th scope="row"><label><?php esc_html_e( 'From email', 'contact-forms'); ?></label></th>
2263 - <td id="accua_form_emails_from">
2264 - <input class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['emails_from']) ?>" <?php if (!isset($form_overrided_data['emails_from'])) echo 'disabled'; ?> />
2265 - <label><input name="accua_form_emails_from" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_from'])) {echo 'checked="checked" ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2266 - <p class="description"><?php printf( esc_html__( 'Default: %s', 'contact-forms' ), '<code>' . esc_html($default_form_data['emails_from']) . '</code>' ); ?></p>
2267 - </td>
2268 - </tr>
2269 - <tr>
2270 - <th scope="row"><label><?php esc_html_e( 'Subject', 'contact-forms'); ?></label></th>
2271 - <td id="accua_form_confirmation_emails_subject">
2272 - <input class="accua_form_value regular-text" type="text" value="<?php echo esc_attr($form_data['confirmation_emails_subject']) ?>" <?php if (!isset($form_overrided_data['confirmation_emails_subject'])) echo 'disabled'; ?> />
2273 - <label><input name="accua_form_confirmation_emails_subject" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['confirmation_emails_subject'])) {echo 'checked="checked" ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2274 - <p class="description"><?php printf( esc_html__( 'Default: %s', 'contact-forms' ), '<code>' . esc_html($default_form_data['confirmation_emails_subject']) . '</code>' ); ?></p>
2275 - </td>
2276 - </tr>
2277 - </table>
1488 + <div class="metabox-holder accua-forms-metabox-holder">
1489 + <div class="postbox ">
1490 + <h3 class="hndle"><span><?php _e('4. Email confirmation to the person who completed the form', 'contact-forms'); ?></span></h3>
1491 + <div class="inside" id="dashboard_right_now">
1492 + <div id="accua_form_emails_from_name" class="label_input">
1493 + <label><?php _e( 'From name', 'contact-forms'); ?></label>
1494 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['emails_from_name']); ?></div>
1495 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_from_name'], ENT_QUOTES) ?>" />
1496 + <input name="accua_form_emails_from_name" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_from_name'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?>
1497 + </div>
1498 + <div id="accua_form_emails_from" class="label_input">
1499 + <label><?php _e( 'From email', 'contact-forms'); ?></label>
1500 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['emails_from']); ?></div>
1501 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_from'], ENT_QUOTES) ?>" />
1502 + <input name="accua_form_emails_from" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_from'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?>
1503 + </div>
1504 + <div id="accua_form_confirmation_emails_subject" class="label_input">
1505 + <label><?php _e( 'Subject', 'contact-forms'); ?></label>
1506 + <div class="default_value"><?php echo htmlspecialchars($default_form_data['confirmation_emails_subject']); ?></div>
1507 + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['confirmation_emails_subject'], ENT_QUOTES) ?>" />
1508 + <input name="accua_form_confirmation_emails_subject" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['confirmation_emails_subject'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?>
1509 + </div>
2278 1510
2279 1511 <div id="accua_form_confirmation_emails_message">
2280 - <fieldset class="accua-radio-group">
2281 - <label><input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="0" <?php if (!isset($form_overrided_data['confirmation_emails_message'])) {echo ' checked ';} ?>> <?php esc_html_e( 'Use the default message', 'contact-forms' ); ?></label>
2282 - <label><input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="1" <?php if (isset($form_overrided_data['confirmation_emails_message']) && !isset($form_overrided_data['confirmation_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php esc_html_e( 'Customize', 'contact-forms' ); ?></label>
2283 - <label><input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="-1" <?php if (isset($form_overrided_data['confirmation_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php esc_html_e( 'Don\'t show any messages', 'contact-forms' ); ?></label>
2284 - </fieldset>
1512 + <input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="0" <?php if (!isset($form_overrided_data['confirmation_emails_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'contact-forms'); ?>
1513 + <input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="1" <?php if (isset($form_overrided_data['confirmation_emails_message']) && !isset($form_overrided_data['confirmation_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'contact-forms'); ?>
1514 + <input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="-1" <?php if (isset($form_overrided_data['confirmation_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'contact-forms'); ?><br />
2285 1515 <div class="defalut_message">
2286 - <?php esc_html_e( 'Default message', 'contact-forms' ); ?>
2287 - <div class="defalut_content_message"><?php echo wp_kses_post( wpautop( $default_form_data['confirmation_emails_message'] ) ); ?></div>
1516 + <?php _e( 'Default message', 'contact-forms'); ?>
1517 + <div class="defalut_content_message"><?php echo wpautop($default_form_data['confirmation_emails_message']); ?></div>
2288 1518 </div>
2289 1519 <?php wp_editor( $form_data['confirmation_emails_message'] , 'accua_form_confirmation_emails_message_textarea' , $settings_editor); ?>
2290 1520 </div>
2291 - </div>
1521 + </div>
1522 + </div>
2292 1523 </div>
2293 - </div><!-- /.accua-settings-grid -->
2294 - </div><!-- /panel: messages -->
1524 + <br clear="all"/>
2295 1525
2296 - <div id="accua_tab_tokens" class="accua-tabs__panel" role="tabpanel" data-tab="tokens">
2297 - <div class="postbox">
2298 - <div class="postbox-header"><h2><?php esc_html_e( 'Tokens', 'contact-forms' ); ?></h2></div>
2299 - <div class="inside">
2300 - <?php accua_forms_print_tokens(); ?>
2301 - </div>
2302 - </div>
2303 -</div>
1526 +<?php accua_forms_print_tokens(); ?>
2304 1527
2305 -<div id="accua_tab_retention" class="accua-tabs__panel" role="tabpanel" data-tab="retention">
2306 -<?php
2307 - $global_retention = get_option( 'accua_forms_retention_data', array() );
2308 - $global_retention = wp_parse_args( $global_retention, array( 'retention_value' => 0, 'retention_unit' => 'months', 'retention_mode' => 'anonymize' ) );
2309 - $global_val = (int) $global_retention['retention_value'];
2310 - $global_unit = $global_retention['retention_unit'];
2311 - $global_mode = $global_retention['retention_mode'];
2312 - $unit_labels = array( 'days' => __( 'days', 'contact-forms' ), 'months' => __( 'months', 'contact-forms' ), 'years' => __( 'years', 'contact-forms' ) );
2313 - $mode_labels = array( 'anonymize' => __( 'Anonymize', 'contact-forms' ), 'delete' => __( 'Delete permanently', 'contact-forms' ) );
2314 - if ( $global_val > 0 ) {
2315 - $global_summary = sprintf( '%d %s — %s', $global_val, $unit_labels[ $global_unit ] ?? $global_unit, $mode_labels[ $global_mode ] ?? $global_mode );
2316 - } else {
2317 - $global_summary = __( 'Keep indefinitely', 'contact-forms' );
2318 - }
2319 -?>
2320 - <div class="postbox">
2321 - <div class="postbox-header"><h2><?php esc_html_e('Data Retention', 'contact-forms'); ?></h2></div>
2322 - <div class="inside">
2323 - <table class="form-table" role="presentation">
2324 - <tr>
2325 - <th scope="row"><?php esc_html_e( 'Override', 'contact-forms'); ?></th>
2326 - <td>
2327 - <input type="checkbox" name="submission_retention_override" id="accua_form_retention_override" value="1" <?php checked( ! empty( $form_data['submission_retention_override'] ) ); ?> />
2328 - <label for="accua_form_retention_override"><?php esc_html_e( 'Override default data retention', 'contact-forms'); ?></label>
2329 - <p class="description"><?php
2330 - printf(
2331 - /* translators: %s: current global retention summary, e.g. "12 months — Anonymize" or "Keep indefinitely" */
2332 - esc_html__( 'Global default: %s', 'contact-forms' ),
2333 - '<strong>' . esc_html( $global_summary ) . '</strong>'
2334 - );
2335 - ?></p>
2336 - </td>
2337 - </tr>
2338 - </table>
2339 - <div id="accua_form_retention_fields" style="<?php echo empty( $form_data['submission_retention_override'] ) ? 'display:none;' : ''; ?>">
2340 - <table class="form-table" role="presentation">
2341 - <tr>
2342 - <th scope="row"><label for="submission_retention_value"><?php esc_html_e( 'Retention period', 'contact-forms'); ?></label></th>
2343 - <td>
2344 - <input type="number" id="submission_retention_value" name="submission_retention_value" min="0" step="1" value="<?php echo esc_attr( $form_data['submission_retention_value'] ); ?>" style="width: 80px;" />
2345 - <select name="submission_retention_unit" id="submission_retention_unit">
2346 - <option value="days" <?php selected( $form_data['submission_retention_unit'], 'days' ); ?>><?php esc_html_e( 'days', 'contact-forms'); ?></option>
2347 - <option value="months" <?php selected( $form_data['submission_retention_unit'], 'months' ); ?>><?php esc_html_e( 'months', 'contact-forms'); ?></option>
2348 - <option value="years" <?php selected( $form_data['submission_retention_unit'], 'years' ); ?>><?php esc_html_e( 'years', 'contact-forms'); ?></option>
2349 - </select>
2350 - <span class="description"><?php esc_html_e( '(0 = keep indefinitely)', 'contact-forms'); ?></span>
2351 - </td>
2352 - </tr>
2353 - <tr>
2354 - <th scope="row"><?php esc_html_e( 'When submissions expire', 'contact-forms'); ?></th>
2355 - <td>
2356 - <fieldset>
2357 - <label><input type="radio" name="submission_retention_mode" id="submission_retention_mode_anonymize" value="anonymize" <?php checked( $form_data['submission_retention_mode'], 'anonymize' ); ?> />
2358 - <?php esc_html_e( 'Anonymize — replace personal data with placeholders, keep submission record for statistics', 'contact-forms'); ?></label><br />
2359 - <label><input type="radio" name="submission_retention_mode" id="submission_retention_mode_delete" value="delete" <?php checked( $form_data['submission_retention_mode'], 'delete' ); ?> />
2360 - <?php esc_html_e( 'Delete — permanently remove submission records from the database', 'contact-forms'); ?></label>
2361 - </fieldset>
2362 - </td>
2363 - </tr>
2364 - </table>
2365 - </div>
2366 - </div></div>
2367 -
2368 -</div><!-- /panel: retention -->
2369 -
2370 -<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $fid_esc is pre-escaped with esc_attr() ?>
2371 1528 <input type="hidden" id="accua_form_save_settings_id" value="<?php echo $fid_esc; ?>" />
1529 +</div>
1530 +<?php /*
1531 +<div id="accua_tab_preview" class="content_tab">
1532 +</div> */?>
1533 +<p></p>
1534 +<input class="button button-primary button-large accua_form_save_settings_button" id="accua_form_save_settings_2" type="button" value="<?php _e( 'Save settings', 'contact-forms'); ?>" /> <span class="accua_form_save_settings_status"></span>
2372 1535
2373 -</div><!-- /#accua_tabs -->
1536 +</div>
2374 1537 <script>
2375 1538 jQuery('input[type=radio]').change(function() {
2376 1539 var name = jQuery(this).attr('name');
2377 1540 if (jQuery(this).val() == '1') {
@@ -2386,26 +1549,18 @@
2386 1549 jQuery('#'+name+' .wp-editor-wrap').hide();
2387 1550 }
2388 1551 });
2389 1552
2390 -jQuery('#accua_form_retention_override').on('change', function() {
2391 - jQuery('#accua_form_retention_fields').toggle(this.checked);
2392 -});
2393 -
2394 -jQuery('input[type=checkbox].accua_form_check_override').click(function() {
1553 +jQuery('input[type=checkbox]').click(function() {
2395 1554 var name = jQuery(this).attr('name');
2396 - var $container = jQuery('#'+name);
2397 1555 if (!this.checked) {
2398 - $container.find('.default_value').show();
2399 - $container.find('.accua_form_value').prop('disabled', true);
2400 - $container.find('.wp-picker-container').hide();
2401 - $container.find('.accua-style-help').hide();
1556 + jQuery('#'+name+' .default_value').show();
1557 + jQuery('#'+name+' .accua_form_value, #'+name+' .cp-color-picker').hide();
2402 1558 }
2403 1559 else {
2404 - $container.find('.default_value').hide();
2405 - $container.find('.accua_form_value').prop('disabled', false);
2406 - $container.find('.wp-picker-container').show();
2407 - $container.find('.accua-style-help').show();
1560 + jQuery('#'+name+' .default_value').hide();
1561 + jQuery('#'+name+' .accua_form_value, #'+name+' .cp-color-picker').show();
1562 + //cp-color-picker
2408 1563 }
2409 1564 });
2410 1565
2411 1566 jQuery(".token_link").click(function() {
@@ -2440,20 +1595,15 @@
2440 1595 );
2441 1596 $.each(
2442 1597 ['emails_from_name','emails_from','admin_emails_to','emails_bcc','admin_emails_subject','confirmation_emails_subject','style_margin','style_border_color','style_border_width','style_border_radius','style_background_color','style_padding','style_color','style_font_size','style_field_spacing','style_field_border_color','style_field_border_width','style_field_border_radius','style_field_background_color','style_field_padding','style_field_color','style_submit_border_color','style_submit_border_width','style_submit_border_radius','style_submit_background_color','style_submit_padding','style_submit_color','style_submit_font_size'],
2443 1598 function(i,key){
2444 - var $container = $('#accua_form_'+key);
2445 - if(!$container.find('.accua_form_check_override').is(':checked')) {
2446 - $container.find('.default_value').show();
2447 - $container.find('.accua_form_value').prop('disabled', true);
2448 - $container.find('.wp-picker-container').hide();
2449 - $container.find('.accua-style-help').hide();
1599 + if(!$('#accua_form_'+key+' .accua_form_check_override').is(':checked')) {
1600 + jQuery('#accua_form_'+key+' .default_value').show();
1601 + jQuery('#accua_form_'+key+' .accua_form_value, #accua_form_'+key+' .wp-picker-container').hide();
2450 1602 }
2451 1603 else {
2452 - $container.find('.default_value').hide();
2453 - $container.find('.accua_form_value').prop('disabled', false);
2454 - $container.find('.wp-picker-container').show();
2455 - $container.find('.accua-style-help').show();
1604 + jQuery('#accua_form_'+key+' .default_value').hide();
1605 + jQuery('#accua_form_'+key+' .accua_form_value, #accua_form_'+key+' .wp-picker-container').show();
2456 1606 }
2457 1607 });
2458 1608 $("#dialog_token").dialog({ dialogClass:'wp-dialog' ,autoOpen : false, modal : true, show : "blind", hide : "blind"});
2459 1609
@@ -2563,14 +1713,13 @@
2563 1713 */
2564 1714 }
2565 1715
2566 1716 function accua_forms_fields_get_types() {
2567 - $types = array(
1717 + return array(
2568 1718 'textfield' => __( 'Text Field', 'contact-forms'),
2569 1719 'textarea' => __( 'Text Area', 'contact-forms'),
2570 1720 'email' => __( 'Email', 'contact-forms'),
2571 1721 'autoreply_email' => __( 'Autoreply Email', 'contact-forms'),
2572 - 'telephone' => __( 'Telephone', 'contact-forms'),
2573 1722 'checkbox' => __( 'Checkbox','contact-forms'),
2574 1723 'select' => __('Select', 'contact-forms'),
2575 1724 'radio' => __( 'Radio buttons', 'contact-forms'),
2576 1725 'multiselect' => __( 'Multiple selections area', 'contact-forms'),
@@ -2586,15 +1735,8 @@
2586 1735 'password' => 'Password',
2587 1736 'password-and-confirm' => __( 'Password and password confirmation','contact-forms'),
2588 1737 'date' => __( 'Date','contact-forms'),
2589 1738 );
2590 -
2591 - /**
2592 - * Filter the available field types.
2593 - *
2594 - * @param array $types Associative array of type_id => label.
2595 - */
2596 - return apply_filters( 'accua_forms_field_types', $types );
2597 1739 }
2598 1740
2599 1741 function accua_forms_filter_date($value){
2600 1742 if (($value !== '') && preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
@@ -2622,10 +1764,8 @@
2622 1764 'allowed_values' => $post['form-field-allowed-values'],
2623 1765 'allowed_extensions' => '',
2624 1766 'min_date' => $post['form-field-min-of-date'],
2625 1767 'max_date' => $post['form-field-max-of-date'],
2626 - 'custom_required_message' => sanitize_text_field($post['form-field-custom-required-message']),
2627 - 'custom_format_message' => sanitize_text_field($post['form-field-custom-format-message']),
2628 1768 );
2629 1769 $valid = true;
2630 1770 $message = '';
2631 1771
@@ -2717,10 +1857,8 @@
2717 1857 'allowed_values' => '',
2718 1858 'allowed_extensions' => '',
2719 1859 'min_date' => '',
2720 1860 'max_date' => '',
2721 - 'custom_required_message' => '',
2722 - 'custom_format_message' => '',
2723 1861 );
2724 1862
2725 1863 $editing = false;
2726 1864 $adding = true;
@@ -2730,21 +1868,19 @@
2730 1868 $post = stripslashes_deep($_POST) + $default_form_values;
2731 1869 switch($post['action']) {
2732 1870 case 'edit-form-field':
2733 1871 if (empty($avail_fields[$post['form-field-id']])) {
2734 - $message .= 'Field "'.esc_html(sanitize_text_field($post['form-field-id'])).'" doesn\'t exists';
1872 + $message .= 'Field "'.htmlspecialchars(sanitize_text_field($post['form-field-id'])).'" doesn\'t exists';
2735 1873 } else {
2736 1874 if (empty($post['delete-field'])) {
2737 1875 $filtered_data = accua_forms_fields_filter_values($post, $avail_fields[$post['form-field-id']]);
2738 1876 $avail_fields[$post['form-field-id']] = $filtered_data['data'];
2739 - /* translators: %s is the field slug */
2740 - $message .= sprintf( __( 'Field "%s" updated', 'contact-forms'), esc_html($post['form-field-id']) );
1877 + $message .= sprintf( __( 'Field "%s" updated', 'contact-forms'), htmlspecialchars($post['form-field-id']) );
2741 1878 do_action('accua_forms_field_updated', $avail_fields[$post['form-field-id']]);
2742 1879 } else {
2743 1880 $deleting_field = $avail_fields[$post['form-field-id']];
2744 1881 unset ($avail_fields[$post['form-field-id']]);
2745 - /* translators: %s is the field slug */
2746 - $message .= sprintf( __( 'Field "%s" deleted', 'contact-forms'), esc_html($post['form-field-id']) );
1882 + $message .= sprintf( __( 'Field "%s" deleted', 'contact-forms'), htmlspecialchars($post['form-field-id']) );
2747 1883 do_action('accua_forms_field_deleted', $deleting_field);
2748 1884 }
2749 1885 update_option('accua_forms_avail_fields', $avail_fields);
2750 1886 }
@@ -2752,22 +1888,21 @@
2752 1888 case 'add-form-field':
2753 1889 $fill_form_fields = true;
2754 1890 $valid = true;
2755 1891 if (empty($post['form-field-id']) || !preg_match('/^[a-z0-9_-]+$/i', $post['form-field-id'])) {
2756 - $message .= "<p>".__( 'Only letters, numbers, hyphens, and underscores allowed in field slug', 'contact-forms')."</p>";
1892 + $message .= "<p>".__( 'Only letters, numbers, hyphen and underscores allowed in field identificative slug', 'contact-forms')."</p>";
2757 1893 $valid = false;
2758 1894 }
2759 1895 if(substr($post['form-field-id'], 0, 2) == '__') {
2760 - $message .= "<p>".__( 'The field slug cannot start with two underscores (__)', 'contact-forms')."</p>";
1896 + $message .= "<p>".__( 'The field identificative slug can\'t start with two underscores (__)', 'contact-forms')."</p>";
2761 1897 $valid = false;
2762 1898 }
2763 1899 if (!empty($avail_fields[$post['form-field-id']])) {
2764 - /* translators: %s is the field slug */
2765 - $message .= sprintf( __( '<p>A field with slug "%s" already exists.</p><p>Field was not added.</p>', 'contact-forms'), esc_html($post['form-field-id']) );
1900 + $message .= sprintf( __( '<p>A field with identificative slug "%s" already exists</p> Field "%s" deleted', 'contact-forms'), htmlspecialchars($post['form-field-id']) );
2766 1901 $valid = false;
2767 1902 }
2768 1903 if (strlen($post['form-field-id']) > 70) {
2769 - $message .= "<p>".__( 'The field slug cannot be longer than 70 characters', 'contact-forms')."</p>";
1904 + $message .= "<p>".__( 'The identificative slug cannot be longer than 70 characters', 'contact-forms')."</p>";
2770 1905 $valid = false;
2771 1906 }
2772 1907 $filtered_data = accua_forms_fields_filter_values($post);
2773 1908 $message .= $filtered_data['message'];
@@ -2775,10 +1910,9 @@
2775 1910 if ($valid) {
2776 1911 $fill_form_fields = false;
2777 1912 $avail_fields[$post['form-field-id']] = $filtered_data['data'];
2778 1913 update_option('accua_forms_avail_fields', $avail_fields);
2779 - /* translators: %s is the field slug */
2780 - $message .= sprintf( __( 'Field "%s" created', 'contact-forms'), esc_html($post['form-field-id']) );
1914 + $message .= sprintf( __( 'Field "%s" created', 'contact-forms'), htmlspecialchars($post['form-field-id']) );
2781 1915 do_action('accua_forms_field_added', $avail_fields[$post['form-field-id']]);
2782 1916 }
2783 1917 if ($fill_form_fields) {
2784 1918 $editing = true;
@@ -2785,14 +1919,12 @@
2785 1919 $default_form_values = $filtered_data['data'];
2786 1920 }
2787 1921 break;
2788 1922 }
2789 - } elseif (!empty($_GET['edit-fid'])) {
2790 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only field lookup
2791 - $fid = sanitize_text_field(wp_unslash($_GET['edit-fid']));
1923 + } else if (!empty($_GET['edit-fid'])) {
1924 + $fid = stripslashes($_GET['edit-fid']);
2792 1925 if (empty($avail_fields[$fid])) {
2793 - /* translators: %s is the field slug */
2794 - $message .= sprintf( __( 'Field "%s" doesn\'t exists', 'contact-forms'), esc_html($fid) );
1926 + $message .= sprintf( __( 'Field "%s" doesn\'t exists', 'contact-forms'), htmlspecialchars($fid) );
2795 1927 } else {
2796 1928 $adding = false;
2797 1929 $editing = true;
2798 1930 $default_form_values = $avail_fields[$fid] + $default_form_values;
@@ -2804,9 +1936,9 @@
2804 1936 }
2805 1937
2806 1938 ?>
2807 1939 <div id="accua_forms_fields_page" class="accua_forms_admin_page wrap nosubsub">
2808 -<h1><?php esc_html_e('Contact Forms - Fields', 'contact-forms'); ?></h1>
1940 +<h2><img src="<?php echo ACCUA_FORMS_DIR_URL.'img/cimatti-icon-20.png'; ?>"/> <?php _e('Contact Forms - Fields', 'contact-forms'); ?></h2>
2809 1941 <?php /* screen_icon(); ?>
2810 1942 <h2><?php echo esc_html( $title );
2811 1943 if ( !empty($_REQUEST['s']) )
2812 1944 printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
@@ -2815,9 +1947,9 @@
2815 1947 <?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?>
2816 1948 <div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div>
2817 1949 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
2818 1950 endif; */ ?>
2819 -<div id="ajax-response"><?php echo wp_kses_post( $message ); ?></div>
1951 +<div id="ajax-response"><?php echo $message?></div>
2820 1952
2821 1953 <?php /*
2822 1954 <form class="search-form" action="" method="get">
2823 1955 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
@@ -2844,12 +1976,12 @@
2844 1976 <table cellspacing="0" class="wp-list-table widefat fixed tags">
2845 1977 <thead>
2846 1978 <tr>
2847 1979 <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox" /></th>
2848 - <th style="" class="manage-column column-name" id="name" scope="col"><?php esc_html_e( 'Label', 'contact-forms'); ?></th>
2849 - <th style="" class="manage-column column-description" id="description" scope="col"><?php esc_html_e( 'Description', 'contact-forms'); ?></th>
2850 - <th style="" class="manage-column column-slug" id="slug" scope="col"><?php esc_html_e( 'Slug', 'contact-forms'); ?></th>
2851 - <th style="" class="manage-column column-type" id="type" scope="col"><?php esc_html_e( 'Type', 'contact-forms'); ?></th>
1980 + <th style="" class="manage-column column-name" id="name" scope="col"><?php _e( 'Label', 'contact-forms'); ?></th>
1981 + <th style="" class="manage-column column-description" id="description" scope="col"><?php _e( 'Description', 'contact-forms'); ?></th>
1982 + <th style="" class="manage-column column-slug" id="slug" scope="col"><?php _e( 'Slug', 'contact-forms'); ?></th>
1983 + <th style="" class="manage-column column-type" id="type" scope="col"><?php _e( 'Type', 'contact-forms'); ?></th>
2852 1984 </tr>
2853 1985 </thead>
2854 1986
2855 1987 <tfoot>
@@ -2854,12 +1986,12 @@
2854 1986
2855 1987 <tfoot>
2856 1988 <tr>
2857 1989 <th style="" class="manage-column column-cb check-column" scope="col"><input type="checkbox" /></th>
2858 - <th style="" class="manage-column column-name" scope="col"><?php esc_html_e( 'Label', 'contact-forms'); ?></th>
2859 - <th style="" class="manage-column column-description" scope="col"><?php esc_html_e( 'Description', 'contact-forms'); ?></th>
2860 - <th style="" class="manage-column column-slug" scope="col"><?php esc_html_e( 'Slug', 'contact-forms'); ?></th>
2861 - <th style="" class="manage-column column-type" scope="col"><?php esc_html_e( 'Type', 'contact-forms'); ?></th>
1990 + <th style="" class="manage-column column-name" scope="col"><?php _e( 'Label', 'contact-forms'); ?></th>
1991 + <th style="" class="manage-column column-description" scope="col"><?php _e( 'Description', 'contact-forms'); ?></th>
1992 + <th style="" class="manage-column column-slug" scope="col"><?php _e( 'Slug', 'contact-forms'); ?></th>
1993 + <th style="" class="manage-column column-type" scope="col"><?php _e( 'Type', 'contact-forms'); ?></th>
2862 1994 </tr>
2863 1995 </tfoot>
2864 1996
2865 1997 <tbody class="list:tag" id="the-list">
@@ -2864,16 +1996,12 @@
2864 1996
2865 1997 <tbody class="list:tag" id="the-list">
2866 1998 <?php
2867 1999 foreach ($avail_fields as $id => $field) {
2868 - if ( ! isset( $field['id'] ) ) { $field['id'] = $id; }
2869 - if ( ! isset( $field['name'] ) ) { $field['name'] = $field['label'] ?? $id; }
2870 - $field = array_merge(array('id' => '', 'name' => '', 'type' => '', 'description' => ''), $field);
2871 2000 foreach (array('id', 'name', 'type', 'description') as $i) {
2872 - $field[$i] = esc_attr($field[$i]);
2001 + $field[$i] = htmlspecialchars($field[$i], ENT_QUOTES);
2873 2002 $field[$i] = sanitize_text_field($field[$i]);
2874 2003 }
2875 - // phpcs:disable PluginCheck.CodeAnalysis.Heredoc.NotAllowed, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped -- Heredoc for HTML row with pre-escaped variables
2876 2004 echo <<<END_OF_ROW
2877 2005 <tr id="field-{$field['id']}">
2878 2006 <th class="check-column" scope="row"><input type="checkbox" /></th>
2879 2007 <td class="name column-name"><strong><a title="Edit “{$field['name']}”" href="admin.php?page=accua_forms_fields&amp;edit-fid={$field['id']}" class="row-title">{$field['name']}</a></strong><br><div class="row-actions"><span class="edit"><a href="admin.php?page=accua_forms_fields&amp;edit-fid={$field['id']}">Edit</a></span></div></td>
@@ -2881,9 +2009,8 @@
2881 2009 <td class="slug column-slug">{$field['id']}</td>
2882 2010 <td class="type column-type">{$field['type']}</td>
2883 2011 </tr>
2884 2012 END_OF_ROW;
2885 - // phpcs:enable PluginCheck.CodeAnalysis.Heredoc.NotAllowed, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped
2886 2013 }
2887 2014 ?>
2888 2015 </tbody>
2889 2016 </table>
@@ -2946,9 +2073,9 @@
2946 2073
2947 2074 $types = accua_forms_fields_get_types();
2948 2075 ?>
2949 2076 <div class="form-wrap">
2950 -<h3><?php echo $adding ? esc_html__( 'Add new field', 'contact-forms' ) : esc_html__( 'Edit field', 'contact-forms' ); ?></h3>
2077 +<h3><?php echo $adding? __( 'Add new field','contact-forms'): __( 'Edit field','contact-forms') ; ?></h3>
2951 2078 <form id="addtag" method="post" action="admin.php?page=accua_forms_fields" class="validate">
2952 2079 <input type="hidden" name="action" value="<?php echo $adding?'add':'edit'; ?>-form-field" />
2953 2080 <?php /*
2954 2081 <input type="hidden" name="screen" value="<?php echo esc_attr($current_screen->id); ?>" />
@@ -2957,21 +2084,21 @@
2957 2084 */ ?>
2958 2085 <?php wp_nonce_field('edit_form_field', '_wpnonce_edit_form_field'); ?>
2959 2086
2960 2087 <div class="form-field form-required">
2961 - <label for="tag-name"><?php esc_html_e( 'Field label', 'contact-forms'); ?></label>
2962 - <input name="form-field-name" id="tag-name" type="text" value="<?php echo esc_attr($default_form_values['name']) ?>" size="40" aria-required="true" />
2963 - <p><?php esc_html_e('The name is how it appears on your site.', 'contact-forms'); ?></p>
2088 + <label for="tag-name"><?php _e( 'Field label', 'contact-forms'); ?></label>
2089 + <input name="form-field-name" id="tag-name" type="text" value="<?php echo htmlspecialchars($default_form_values['name'], ENT_QUOTES) ?>" size="40" aria-required="true" />
2090 + <p><?php _e('The name is how it appears on your site.', 'contact-forms'); ?></p>
2964 2091 </div>
2965 2092 <?php /* if ( ! global_terms_enabled() ) : */ ?>
2966 2093 <div class="form-field">
2967 - <label for="tag-slug"><?php esc_html_e( 'Field slug (identifier)', 'contact-forms'); ?></label>
2968 - <input name="form-field-id" id="tag-slug" type="text" value="<?php echo esc_attr($default_form_values['id']) ?>" <?php if (!$adding) { echo 'disabled="disabled"'; } ?> size="40" />
2969 - <?php if (!$adding) { echo '<input type="hidden" name="form-field-id" value="'.esc_attr($default_form_values['id']).'" />'; } ?>
2970 - <p><?php esc_html_e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is used as a unique identifier and cannot be changed. It is usually all lowercase and must contain only letters, numbers, and underscores.', 'contact-forms'); ?></p>
2094 + <label for="tag-slug"><?php _e( 'Field slug (identificative)', 'contact-forms'); ?></label>
2095 + <input name="form-field-id" id="tag-slug" type="text" value="<?php echo htmlspecialchars($default_form_values['id'], ENT_QUOTES) ?>" <?php if (!$adding) { echo 'disabled="disabled"'; } ?> size="40" />
2096 + <?php if (!$adding) { echo '<input type="hidden" name="form-field-id" value="'.htmlspecialchars($default_form_values['id'], ENT_QUOTES).'" />'; } ?>
2097 + <p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is used as an identificator, and is unchangeable. It is usually all lowercase and it must contains only letters, numbers, and underscores.', 'contact-forms'); ?></p>
2971 2098 </div>
2972 2099 <div class="form-field">
2973 - <label for="parent"><?php esc_html_e( 'Field type', 'contact-forms'); ?></label>
2100 + <label for="parent"><?php _e( 'Field type', 'contact-forms'); ?></label>
2974 2101 <select class="postform" id="parent" name="form-field-type">
2975 2102 <?php /*
2976 2103 <option value="textfield" class="level-0" <?php echo ($default_form_values['type'] == 'textfield')?'selected="selected"':'';?> >Text Field</option>
2977 2104 <option value="textarea" class="level-0" <?php echo ($default_form_values['type'] == 'textarea')?'selected="selected"':'';?> >Text Area</option>
@@ -2980,13 +2107,11 @@
2980 2107 <option value="select" class="level-0" <?php echo ($default_form_values['type'] == 'select')?'selected="selected"':'';?> >Select</option>
2981 2108 */
2982 2109 foreach ($types as $typeid => $typename) {
2983 2110 $selected = ($default_form_values['type'] == $typeid)?'selected="selected"':'';
2984 - // phpcs:disable PluginCheck.CodeAnalysis.Heredoc.NotAllowed, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped -- Heredoc for option element with pre-escaped variables
2985 2111 echo <<<EOT
2986 2112 <option value="{$typeid}" class="level-0" {$selected} >{$typename}</option>
2987 2113 EOT;
2988 - // phpcs:enable PluginCheck.CodeAnalysis.Heredoc.NotAllowed, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped
2989 2114 }
2990 2115
2991 2116 ?>
2992 2117 </select>
@@ -3001,56 +2126,42 @@
3001 2126 <?php endif; ?>
3002 2127 </div>
3003 2128 <?php endif; // is_taxonomy_hierarchical() */ ?>
3004 2129 <div class="form-field">
3005 - <label for="tag-description"><?php esc_html_e( 'Field description', 'contact-forms'); ?></label>
3006 - <textarea name="form-field-description" id="tag-description" rows="5" cols="40"><?php echo esc_textarea($default_form_values['description']) ?></textarea>
3007 - <p><?php esc_html_e('The description is not prominent by default; however, some themes may show it.', 'contact-forms'); ?></p>
2130 + <label for="tag-description"><?php _e( 'Field description', 'contact-forms'); ?></label>
2131 + <textarea name="form-field-description" id="tag-description" rows="5" cols="40"><?php echo htmlspecialchars($default_form_values['description'], ENT_QUOTES) ?></textarea>
2132 + <p><?php _e('The description is not prominent by default; however, some themes may show it.', 'contact-forms'); ?></p>
3008 2133 </div>
3009 2134
3010 2135 <div class="form-field">
3011 - <label for="form-field-default-value"><?php esc_html_e( 'Default value(s)', 'contact-forms'); ?>:</label>
3012 - <textarea name="form-field-default-value" id="form-field-default-value" rows="5" cols="40"><?php echo esc_textarea($default_form_values['default_value']) ?></textarea>
3013 - <p><?php esc_html_e( 'For multiple default values in multiple select and multiple checkboxes, use | as separator.', 'contact-forms'); ?></p>
2136 + <label for="form-field-default-value"><?php _e( 'Default value(s)', 'contact-forms'); ?>:</label>
2137 + <textarea name="form-field-default-value" id="form-field-default-value" rows="5" cols="40"><?php echo htmlspecialchars($default_form_values['default_value'], ENT_QUOTES) ?></textarea>
2138 + <p><?php _e( 'For multiple default values in multiple select and multiple checkboxes, use | as separator.', 'contact-forms'); ?></p>
3014 2139 </div>
3015 2140
3016 2141 <div class="form-field">
3017 - <label for="form-field-allowed-values"><?php esc_html_e( 'Allowed values', 'contact-forms'); ?>:</label>
3018 - <textarea rows="5" cols="40" name="form-field-allowed-values" id=form-field-allowed-values"><?php echo esc_textarea($default_form_values['allowed_values']) ?></textarea>
3019 - <p><?php esc_html_e( 'Options used in select, radio and multiple checkboxes. Enter one value per line, in the format key|label. The key is the value that will be stored in the database. The label is optional, and the key will be used as the label if no label is specified. For file fields, this indicates allowed extensions (one per line without dot)', 'contact-forms'); ?></p>
2142 + <label for="form-field-allowed-values"><?php _e( 'Allowed values', 'contact-forms'); ?>:</label>
2143 + <textarea rows="5" cols="40" name="form-field-allowed-values" id=form-field-allowed-values"><?php echo htmlspecialchars($default_form_values['allowed_values'], ENT_QUOTES) ?></textarea>
2144 + <p><?php _e( 'Options used in select, radio and multiple checkboxes. Enter one value per line, in the format key|label. The key is the value that will be stored in the database. The label is optional, and the key will be used as the label if no label is specified. For file fields, this indicates allowed extensions (one per line without dot)', 'contact-forms'); ?></p>
3020 2145 </div>
3021 2146
3022 2147 <div class="form-field">
3023 -<?php esc_html_e( 'Settings for date fields', 'contact-forms'); ?>
2148 +<?php _e( 'Settings for date fields', 'contact-forms'); ?>
3024 2149 <div class="form-field">
3025 - <label for="form-field-default-date-value"><?php esc_html_e( 'Default value', 'contact-forms'); ?>:</label>
3026 - <input type="date" name="form-field-default-date-value" id="form-field-default-date-value" value="<?php echo esc_attr($default_form_values['default_date_value']) ?>">
2150 + <label for="form-field-default-date-value"><?php _e( 'Default value', 'contact-forms'); ?>:</label>
2151 + <input type="date" name="form-field-default-date-value" id="form-field-default-date-value" value="<?php echo htmlspecialchars($default_form_values['default_date_value'], ENT_QUOTES) ?>">
3027 2152 </div>
3028 2153
3029 2154
3030 -<label for="form-field-min-of-date"><?php esc_html_e( 'Min date', 'contact-forms'); ?>:</label>
3031 -<input type="date" id="form-field-min-of-date" name="form-field-min-of-date" value="<?php echo esc_attr($default_form_values['min_date']) ?>">
2155 +<label for="form-field-min-of-date"><?php _e( 'Min date', 'contact-forms'); ?>:</label>
2156 +<input type="date" id="form-field-min-of-date" name="form-field-min-of-date" value="<?php echo htmlspecialchars($default_form_values['min_date'], ENT_QUOTES) ?>">
3032 2157
3033 -<label for="form-field-max-of-date"><?php esc_html_e( 'Max date', 'contact-forms'); ?>:</label>
3034 -<input type="date" id="form-field-max-of-date" name="form-field-max-of-date" value="<?php echo esc_attr($default_form_values['max_date']) ?>">
2158 +<label for="form-field-max-of-date"><?php _e( 'Max date', 'contact-forms'); ?>:</label>
2159 +<input type="date" id="form-field-max-of-date" name="form-field-max-of-date" value="<?php echo htmlspecialchars($default_form_values['max_date'], ENT_QUOTES) ?>">
3035 2160
3036 2161 </div>
3037 2162
3038 -<div class="form-field">
3039 - <label for="form-field-custom-required-message"><?php esc_html_e( 'Custom required message', 'contact-forms'); ?></label>
3040 - <input name="form-field-custom-required-message" id="form-field-custom-required-message" type="text" value="<?php echo esc_attr($default_form_values['custom_required_message']) ?>" />
3041 - <?php // translators: %s is the field name/label placeholder ?>
3042 - <p><?php esc_html_e('Overrides the default "required" error message for this field. Use %s for the field name. Leave blank to use the default translated message.', 'contact-forms'); ?></p>
3043 -</div>
3044 2163
3045 -<div class="form-field">
3046 - <label for="form-field-custom-format-message"><?php esc_html_e( 'Custom format message', 'contact-forms'); ?></label>
3047 - <input name="form-field-custom-format-message" id="form-field-custom-format-message" type="text" value="<?php echo esc_attr($default_form_values['custom_format_message']) ?>" />
3048 - <?php // translators: %s is the field name/label placeholder ?>
3049 - <p><?php esc_html_e('Overrides the default format error message for email and telephone fields. Use %s for the field name. Leave blank to use the default translated message.', 'contact-forms'); ?></p>
3050 -</div>
3051 -
3052 -
3053 2164 <?php
3054 2165 /*
3055 2166 if ( ! is_taxonomy_hierarchical($taxonomy) )
3056 2167 do_action('add_tag_form_fields', $taxonomy);
@@ -3090,9 +2201,9 @@
3090 2201
3091 2202 function accua_forms_settings_page() {
3092 2203 ?>
3093 2204 <div id="accua_forms_settings_page" class="accua_forms_admin_page wrap">
3094 -<h1><?php esc_html_e('Contact Forms - Default Settings', 'contact-forms'); ?></h1>
2205 +<h2><img src="<?php echo ACCUA_FORMS_DIR_URL.'img/cimatti-icon-20.png'; ?>"/> <?php _e('Contact Forms - Default Settings', 'contact-forms'); ?></h2>
3095 2206 <?php
3096 2207 $empty_form_data = array(
3097 2208 'success_message' => '',
3098 2209 'error_message' => '',
@@ -3149,16 +2260,9 @@
3149 2260 $empty_anonymize_ip_data = array(
3150 2261 'anonymize_ip_bytes' => 0,
3151 2262 );
3152 2263
3153 - $empty_retention_data = array(
3154 - 'retention_value' => 0,
3155 - 'retention_unit' => 'months',
3156 - 'retention_mode' => 'anonymize',
3157 - );
3158 -
3159 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- REQUEST_METHOD is always set by server
3160 - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD'] && ! empty( $_POST['accua_form_save_form_settings'] ) ) {
2264 + if($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['accua_form_save_form_settings'])) {
3161 2265 check_admin_referer('accua_form_save_settings', '_nonce_accua_form_save_settings');
3162 2266 $post = stripslashes_deep($_POST);
3163 2267 $post += $empty_form_data;
3164 2268 $post += $empty_file_data;
@@ -3164,15 +2268,13 @@
3164 2268 $post += $empty_file_data;
3165 2269 $post += $empty_captcha_data;
3166 2270 $post += $empty_analytics_data;
3167 2271 $post += $empty_anonymize_ip_data;
3168 - $post += $empty_retention_data;
3169 2272 $form_data = array();
3170 2273 $file_data = array();
3171 2274 $captcha_data = array();
3172 2275 $analytics_data = array();
3173 2276 $anonymize_ip_data = array();
3174 - $retention_data = array();
3175 2277 foreach($empty_form_data as $key=>$val){
3176 2278 $form_data[$key] = $post[$key];
3177 2279 }
3178 2280 $form_data = accua_forms_filter_settings($form_data);
@@ -3199,9 +2301,9 @@
3199 2301 } */
3200 2302 $anonymize_ip_bytes = (int) $post['anonymize_ip_bytes'];
3201 2303 if ($anonymize_ip_bytes < 0) {
3202 2304 $anonymize_ip_bytes = 0;
3203 - } elseif ($anonymize_ip_bytes > 4) {
2305 + } else if ($anonymize_ip_bytes > 4) {
3204 2306 $anonymize_ip_bytes = 4;
3205 2307 }
3206 2308 $anonymize_ip_data['anonymize_ip_bytes'] = $anonymize_ip_bytes;
3207 2309
@@ -3210,16 +2312,10 @@
3210 2312 update_option('accua_forms_default_captcha_field_data', $captcha_data);
3211 2313 update_option('accua_forms_default_analytics_data', $analytics_data);
3212 2314 update_option('accua_forms_anonymize_ip_data', $anonymize_ip_data);
3213 2315
3214 - $retention_data['retention_value'] = max( 0, (int) $post['retention_value'] );
3215 - $retention_data['retention_unit'] = in_array( $post['retention_unit'], array( 'days', 'months', 'years' ), true ) ? $post['retention_unit'] : 'months';
3216 - $retention_data['retention_mode'] = in_array( $post['retention_mode'], array( 'anonymize', 'delete' ), true ) ? $post['retention_mode'] : 'anonymize';
3217 - update_option('accua_forms_retention_data', $retention_data);
3218 -
3219 2316 if (!empty($post['delete_previous_ip_values'])) {
3220 2317 global $wpdb;
3221 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Admin-only IP anonymization action, no caching needed
3222 2318 $wpdb->query("UPDATE `{$wpdb->prefix}accua_forms_submissions` SET afs_ip = ''");
3223 2319 }
3224 2320 } else {
3225 2321 $form_data = get_option('accua_forms_default_form_data',array()) + $empty_form_data;
@@ -3226,9 +2322,8 @@
3226 2322 $file_data = get_option('accua_forms_default_file_field_data',array()) + $empty_file_data;
3227 2323 $captcha_data = get_option('accua_forms_default_captcha_field_data',array()) + $empty_captcha_data;
3228 2324 $analytics_data = get_option('accua_forms_default_analytics_data',array()) + $empty_analytics_data;
3229 2325 $anonymize_ip_data = get_option('accua_forms_anonymize_ip_data',array()) + $empty_anonymize_ip_data;
3230 - $retention_data = get_option('accua_forms_retention_data',array()) + $empty_retention_data;
3231 2326 }
3232 2327 if ($captcha_data['recaptcha_force_v1']) {
3233 2328 $captcha_data = $empty_captcha_data;
3234 2329 }
@@ -3235,461 +2330,304 @@
3235 2330 ?>
3236 2331 <form method="post">
3237 2332 <?php wp_nonce_field('accua_form_save_settings', '_nonce_accua_form_save_settings'); ?>
3238 2333 <input type="hidden" name="accua_form_save_form_settings" value="1" />
3239 -<div id="accua_settings_tabs" class="accua-tabs accua-tabs--primary" data-default-tab="messages">
3240 - <div class="accua-tabs__tablist" role="tablist" aria-label="<?php esc_attr_e( 'Settings', 'contact-forms' ); ?>">
3241 - <button class="accua-tabs__tab" role="tab" data-tab="messages"><?php esc_html_e( 'Default Messages', 'contact-forms' ); ?></button>
3242 - <button class="accua-tabs__tab" role="tab" data-tab="integrations"><?php esc_html_e( 'Integrations', 'contact-forms' ); ?></button>
3243 - <button class="accua-tabs__tab" role="tab" data-tab="privacy"><?php esc_html_e( 'Privacy', 'contact-forms' ); ?></button>
3244 - <button class="accua-tabs__tab" role="tab" data-tab="styling"><?php esc_html_e( 'Layout & Styling', 'contact-forms' ); ?></button>
3245 - <button class="accua-tabs__tab" role="tab" data-tab="theme_helper"><?php esc_html_e( 'Theme Helper', 'contact-forms' ); ?></button>
3246 - <?php if ( current_user_can( 'manage_options' ) ) : ?>
3247 - <button class="accua-tabs__tab" role="tab" data-tab="danger_zone"><?php esc_html_e( 'Danger Zone', 'contact-forms' ); ?></button>
3248 - <?php endif; ?>
3249 - <button class="accua-tabs__tab" role="tab" data-tab="tokens"><?php esc_html_e( 'Tokens', 'contact-forms' ); ?></button>
3250 - </div>
3251 -
3252 - <div class="accua-tabs__panel" role="tabpanel" data-tab="messages">
2334 +<?php /*
2335 +<p id="accua_form_layout"><?php _e( 'Layout', 'contact-forms'); ?>: <select name="layout" class="accua_form_value"><option value="sidebyside" <?php if ($form_data['layout'] == 'sidebyside') { echo 'selected="selected"'; } ?>>Labels on the left of the fields</option><option value="toplabel" <?php if ($form_data['layout'] == 'toplabel') { echo 'selected="selected"'; } ?>>Labels on top of the fields</option></select></p>
2336 +<p id="accua_form_success_message"><?php _e( 'Success message', 'contact-forms'); ?>:<br /><textarea name="success_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['success_message'], ENT_QUOTES) ?></textarea></p>
2337 +<p id="accua_form_error_message"><?php _e( 'Error message', 'contact-forms'); ?>:<br /><textarea name="error_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['error_message'], ENT_QUOTES) ?></textarea></p>
2338 +<p id="accua_form_emails_from"><?php _e( 'Emails from', 'contact-forms'); ?>: <input name="emails_from" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_from'], ENT_QUOTES) ?>" /></p>
2339 +<p id="accua_form_admin_emails_to"><?php _e( 'Admin emails to', 'contact-forms'); ?>: <input name="admin_emails_to" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_to'], ENT_QUOTES) ?>" /></p>
2340 +<p id="accua_form_emails_bcc"><?php _e( 'Emails bcc', 'contact-forms'); ?>: <input name="emails_bcc" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_bcc'], ENT_QUOTES) ?>" /></p>
2341 +<p id="accua_form_admin_emails_subject"><?php _e( 'Admin email subject', 'contact-forms'); ?>: <input name="admin_emails_subject" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_subject'], ENT_QUOTES) ?>" /></p>
2342 +<p id="accua_form_admin_emails_message"><?php _e( 'Admin email message', 'contact-forms'); ?>:<br /><textarea name="admin_emails_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['admin_emails_message'], ENT_QUOTES) ?></textarea></p>
2343 +<p id="accua_form_confirmation_emails_subject"><?php _e( 'Confirmation email subject', 'contact-forms'); ?>: <input name="confirmation_emails_subject" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['confirmation_emails_subject'], ENT_QUOTES) ?>" /></p>
2344 +<p id="accua_form_confirmation_emails_message"><?php _e( 'Confirmation email message', 'contact-forms'); ?>:<br /><textarea name="confirmation_emails_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['confirmation_emails_message'], ENT_QUOTES) ?></textarea></p>
2345 +*/ ?>
2346 +<div id="accua_tab_messages" class="content_tab">
3253 2347 <?php
3254 - $email_font_formats =
3255 - 'Arial=arial,helvetica,sans-serif;'
3256 - . 'Arial Black=arial black,avant garde,sans-serif;'
3257 - . 'Comic Sans MS=comic sans ms,sans-serif;'
3258 - . 'Courier New=courier new,courier,monospace;'
3259 - . 'Georgia=georgia,palatino,serif;'
3260 - . 'Lucida Sans=lucida sans unicode,lucida grande,sans-serif;'
3261 - . 'Tahoma=tahoma,arial,helvetica,sans-serif;'
3262 - . 'Times New Roman=times new roman,times,serif;'
3263 - . 'Trebuchet MS=trebuchet ms,geneva,sans-serif;'
3264 - . 'Verdana=verdana,geneva,sans-serif;';
3265 -
3266 2348 $settings_editor = array(
3267 2349 'teeny' => true,
3268 2350 'editor_class' => 'accua_form_value',
3269 2351 'tinymce' => array(
3270 - 'toolbar1' => 'fontselect,|,bold,italic,underline,|,bullist,numlist,|,link,unlink',
3271 - 'font_formats' => $email_font_formats,
3272 - 'content_style' => 'body { font-family: arial, helvetica, sans-serif; }',
3273 - ));
2352 + 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,'));
3274 2353 ?>
3275 - <div class="accua-settings-grid">
2354 + <div class="metabox-holder accua-forms-metabox-holder">
2355 + <div class="postbox ">
2356 + <h3 class="hndle"><span><?php _e('1. On-screen success message', 'contact-forms'); ?></span></h3>
2357 + <div class="inside" id="dashboard_right_now">
2358 + <div id="accua_form_success_message">
2359 + <?php wp_editor( $form_data['success_message'] , 'success_message' , $settings_editor); ?>
2360 + </div>
2361 + </div>
2362 + </div>
2363 + </div>
3276 2364
3277 - <div class="postbox">
3278 - <div class="postbox-header"><h2><?php esc_html_e('1. On-screen success message', 'contact-forms'); ?></h2></div>
3279 - <div class="inside">
3280 - <div id="accua_form_success_message">
3281 - <?php wp_editor( $form_data['success_message'] , 'success_message' , $settings_editor); ?>
2365 + <div class="metabox-holder accua-forms-metabox-holder">
2366 + <div class="postbox ">
2367 + <h3 class="hndle"><span><?php _e('2. On-screen error message', 'contact-forms'); ?></span></h3>
2368 + <div class="inside" id="dashboard_right_now">
2369 + <div id="accua_form_error_message">
2370 + <?php wp_editor( $form_data['error_message'] , 'error_message' , $settings_editor); ?>
2371 + </div>
3282 2372 </div>
3283 - <p class="accua-restore-default-wrapper">
3284 - <button type="button" class="button-link accua-restore-default-btn" data-message-type="success_message">
3285 - <?php esc_html_e('Restore default', 'contact-forms'); ?>
3286 - </button>
3287 - </p>
3288 - </div></div>
2373 + </div>
2374 + </div>
2375 + <br clear="all"/>
2376 + <div class="metabox-holder accua-forms-metabox-holder">
2377 + <div class="postbox ">
2378 + <h3 class="hndle"><span><?php _e('3. Email to notify administrator', 'contact-forms'); ?></span></h3>
2379 + <div class="inside" id="dashboard_right_now">
2380 + <div id="accua_form_admin_emails_to" class="label_input">
2381 + <label><?php _e( 'To', 'contact-forms'); ?></label>
2382 + <input name="admin_emails_to" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_to'], ENT_QUOTES) ?>" />
2383 + </div>
2384 + <br clear="all" />
2385 + <div id="accua_form_emails_bcc" class="label_input">
2386 + <label><?php _e( 'Bcc', 'contact-forms'); ?></label>
2387 + <input name="emails_bcc" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_bcc'], ENT_QUOTES) ?>" />
2388 + </div>
2389 + <br clear="all" />
2390 + <div id="accua_form_admin_emails_subject" class="label_input">
2391 + <label><?php _e( 'Subject', 'contact-forms'); ?></label>
2392 + <input name="admin_emails_subject" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_subject'], ENT_QUOTES) ?>" />
2393 + </div>
2394 + <br clear="all" />
2395 + <div id="accua_form_admin_emails_message">
2396 + <?php wp_editor( $form_data['admin_emails_message'] , 'admin_emails_message' , $settings_editor); ?>
2397 + </div>
3289 2398
3290 - <div class="postbox">
3291 - <div class="postbox-header"><h2><?php esc_html_e('2. On-screen error message', 'contact-forms'); ?></h2></div>
3292 - <div class="inside">
3293 - <div id="accua_form_error_message">
3294 - <?php wp_editor( $form_data['error_message'] , 'error_message' , $settings_editor); ?>
3295 - </div>
3296 - <p class="accua-restore-default-wrapper">
3297 - <button type="button" class="button-link accua-restore-default-btn" data-message-type="error_message">
3298 - <?php esc_html_e('Restore default', 'contact-forms'); ?>
3299 - </button>
3300 - </p>
3301 - </div></div>
2399 + </div>
2400 + </div>
2401 + </div>
3302 2402
3303 - <div class="postbox">
3304 - <div class="postbox-header"><h2><?php esc_html_e('3. Email to notify administrator', 'contact-forms'); ?></h2></div>
3305 - <div class="inside">
3306 - <table class="form-table" role="presentation">
3307 - <tr>
3308 - <th scope="row"><label for="accua_settings_admin_emails_to"><?php esc_html_e( 'To', 'contact-forms'); ?></label></th>
3309 - <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>
3310 - </tr>
3311 - <tr>
3312 - <th scope="row"><label for="accua_settings_emails_bcc"><?php esc_html_e( 'Bcc', 'contact-forms'); ?></label></th>
3313 - <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>
3314 - </tr>
3315 - <tr>
3316 - <th scope="row"><label for="accua_settings_admin_emails_subject"><?php esc_html_e( 'Subject', 'contact-forms'); ?></label></th>
3317 - <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>
3318 - </tr>
3319 - </table>
3320 - <div id="accua_form_admin_emails_message">
3321 - <?php wp_editor( $form_data['admin_emails_message'] , 'admin_emails_message' , $settings_editor); ?>
3322 - </div>
3323 - <p class="accua-restore-default-wrapper">
3324 - <button type="button" class="button-link accua-restore-default-btn" data-message-type="admin_emails">
3325 - <?php esc_html_e('Restore default', 'contact-forms'); ?>
3326 - </button>
3327 - <span class="description"><?php esc_html_e('(Restores subject and message only)', 'contact-forms'); ?></span>
3328 - </p>
3329 - </div></div>
2403 + <div class="metabox-holder accua-forms-metabox-holder">
2404 + <div class="postbox ">
2405 + <h3 class="hndle"><span><?php _e('4. Email confirmation to the person who completed the form', 'contact-forms'); ?></span></h3>
2406 + <div class="inside" id="dashboard_right_now">
2407 + <div id="accua_form_emails_from_name" class="label_input">
2408 + <label><?php _e( 'From name', 'contact-forms'); ?></label>
2409 + <input class="accua_form_value" name="emails_from_name" type="text" value="<?php echo htmlspecialchars($form_data['emails_from_name'], ENT_QUOTES) ?>" />
2410 + </div>
2411 + <div id="accua_form_emails_from" class="label_input">
2412 + <label><?php _e( 'From email', 'contact-forms'); ?></label>
2413 + <input class="accua_form_value" name="emails_from" type="text" value="<?php echo htmlspecialchars($form_data['emails_from'], ENT_QUOTES) ?>" />
2414 + </div>
2415 + <br clear="all" />
2416 + <div id="accua_form_confirmation_emails_subject" class="label_input">
2417 + <label><?php _e( 'Subject', 'contact-forms'); ?></label>
2418 + <input class="accua_form_value" type="text" name="confirmation_emails_subject" value="<?php echo htmlspecialchars($form_data['confirmation_emails_subject'], ENT_QUOTES) ?>" />
2419 + </div>
2420 + <br clear="all" />
2421 + <div id="accua_form_confirmation_emails_message">
2422 + <?php wp_editor( $form_data['confirmation_emails_message'] , 'confirmation_emails_message' , $settings_editor); ?>
2423 + </div>
2424 + </div>
2425 + </div>
2426 + </div>
2427 + <br clear="all"/>
3330 2428
3331 - <div class="postbox">
3332 - <div class="postbox-header"><h2><?php esc_html_e('4. Email confirmation to the person who completed the form', 'contact-forms'); ?></h2></div>
3333 - <div class="inside">
3334 - <table class="form-table" role="presentation">
3335 - <tr>
3336 - <th scope="row"><label for="accua_settings_emails_from_name"><?php esc_html_e( 'From name', 'contact-forms'); ?></label></th>
3337 - <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>
3338 - </tr>
3339 - <tr>
3340 - <th scope="row"><label for="accua_settings_emails_from"><?php esc_html_e( 'From email', 'contact-forms'); ?></label></th>
3341 - <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>
3342 - </tr>
3343 - <tr>
3344 - <th scope="row"><label for="accua_settings_confirmation_emails_subject"><?php esc_html_e( 'Subject', 'contact-forms'); ?></label></th>
3345 - <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>
3346 - </tr>
3347 - </table>
3348 - <div id="accua_form_confirmation_emails_message">
3349 - <?php wp_editor( $form_data['confirmation_emails_message'] , 'confirmation_emails_message' , $settings_editor); ?>
3350 - </div>
3351 - <p class="accua-restore-default-wrapper">
3352 - <button type="button" class="button-link accua-restore-default-btn" data-message-type="confirmation_emails">
3353 - <?php esc_html_e('Restore default', 'contact-forms'); ?>
3354 - </button>
3355 - <span class="description"><?php esc_html_e('(Restores subject and message only)', 'contact-forms'); ?></span>
3356 - </p>
3357 - </div></div>
3358 -
3359 - </div>
3360 - </div><!-- /panel: messages -->
3361 -
3362 - <div class="accua-tabs__panel" role="tabpanel" data-tab="integrations">
3363 - <div class="accua-settings-grid">
3364 -
3365 - <div class="postbox">
3366 - <div class="postbox-header"><h2><?php esc_html_e( 'File upload default settings', 'contact-forms'); ?></h2></div>
3367 - <div class="inside">
3368 - <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>
3369 - <small><?php esc_html_e( 'List of valid extensions, without dot, one per line.', 'contact-forms'); ?></small>
2429 + <div class="metabox-holder accua-forms-metabox-holder">
2430 + <div class="postbox ">
2431 + <h3 class="hndle"><span><?php _e( 'File upload default settings', 'contact-forms'); ?></span></h3>
2432 + <div class="inside" id="dashboard_right_now">
2433 + <div 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>
2434 + <small><?php _e( 'List of valid extensions, without dot, one per line.', 'contact-forms'); ?></small>
3370 2435 </div>
3371 - <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 />
3372 - <small><?php esc_html_e( 'You can use suffix K, M or G for kilobyte, megabyte or gigabyte.', 'contact-forms'); ?>
2436 + <div 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 />
2437 + <small><?php _e( 'You can use suffix K, M or G for kilobyte, megabyte or gigabyte.', 'contact-forms'); ?>
3373 2438 <?php
3374 2439 $server_max_size = AccuaForm_Element_File::file_upload_max_size();
3375 2440 if ($server_max_size > 0) {
3376 - esc_html_e( 'This value is limited by server upload limits of ', 'contact-forms');
3377 - echo esc_html( AccuaForm_Element_File::format_size( $server_max_size ) ) . '. ';
3378 - esc_html_e( 'If you need a greater limit you should ask to the server administrator.', 'contact-forms');
2441 + _e( 'This value is limited by server upload limits of ', 'contact-forms');
2442 + echo AccuaForm_Element_File::format_size($server_max_size).". ";
2443 + _e( 'If you need a greater limit you should ask to the server administrator.', 'contact-forms');
3379 2444 }
3380 2445 ?>
3381 2446 </small>
3382 2447 </div>
3383 2448 <?php if (current_user_can('edit_files') || current_user_can('install_plugins')) { ?>
3384 - <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']) ?>" />
3385 - <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>
2449 + <div 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) ?>" />
2450 + <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>
3386 2451 </div>
3387 2452 <?php } ?>
3388 - </div></div>
2453 + </div>
2454 + </div>
3389 2455
3390 - <div class="postbox">
3391 - <div class="postbox-header"><h2><?php esc_html_e( 'reCaptcha settings', 'contact-forms'); ?></h2></div>
3392 - <div class="inside">
3393 - <p><?php esc_html_e( 'As reCAPTCHA v1 is discontinued, only reCAPTCHA v2 is supported', 'contact-forms');?></p>
3394 - <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML with hardcoded link is intentional ?>
2456 + <div class="postbox ">
2457 + <h3 class="hndle"><span><?php _e( 'reCaptcha settings', 'contact-forms'); ?></span></h3>
2458 + <div class="inside" id="dashboard_right_now">
2459 + <p><?php _e( 'As reCAPTCHA v1 is discontinued, only reCAPTCHA v2 is supported', 'contact-forms');?></p>
3395 2460 <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>
3396 - <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']) ?>" />
2461 + <div id="accua_form_recaptcha_public_key"><?php _e('Site key', 'contact-forms');?> : <input name="recaptcha_public_key" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($captcha_data['recaptcha_public_key'], ENT_QUOTES) ?>" />
3397 2462 </div>
3398 - <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']) ?>" />
2463 + <div id="accua_form_recaptcha_private_key"><?php _e('Secret key', 'contact-forms');?> : <input name="recaptcha_private_key" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($captcha_data['recaptcha_private_key'], ENT_QUOTES) ?>" />
3399 2464 </div>
3400 - </div></div>
2465 + </div>
2466 + </div>
3401 2467
3402 - <div class="postbox">
3403 - <div class="postbox-header"><h2><?php esc_html_e( 'Cloudflare Turnstile settings', 'contact-forms'); ?></h2></div>
3404 - <div class="inside">
3405 - <p><?php esc_html_e( 'Cloudflare Turnstile is a modern CAPTCHA alternative that provides bot protection without frustrating user experiences.', 'contact-forms');?></p>
3406 - <?php
3407 - $turnstile_plugin_installed = function_exists('cfturnstile_field_show');
3408 - if (!$turnstile_plugin_installed) {
3409 - echo '<div class="notice notice-warning inline"><p>';
3410 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML with hardcoded link is intentional
3411 - echo strtr(__('<strong>Required Plugin:</strong> The Turnstile field requires the %PLUGINLINK% plugin to be installed and activated.', 'contact-forms'), array(
3412 - '%PLUGINLINK%' => '<a href="https://it.wordpress.org/plugins/simple-cloudflare-turnstile/" target="_blank">Simple Cloudflare Turnstile</a>'
3413 - ));
3414 - echo '</p></div>';
3415 - } else {
3416 - $turnstile_key = get_option('cfturnstile_key', '');
3417 - $turnstile_secretkey = get_option('cfturnstile_secretkey', '');
3418 - if (empty($turnstile_key) || empty($turnstile_secretkey)) {
3419 - echo '<div class="notice notice-info inline"><p>';
3420 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML with esc_url() link is intentional
3421 - echo strtr(__('The plugin is installed. Please configure your Cloudflare Turnstile keys in %SETTINGSLINK%.', 'contact-forms'), array(
3422 - '%SETTINGSLINK%' => '<a href="' . esc_url( admin_url('options-general.php?page=cfturnstile') ) . '">Settings &rarr; Cloudflare Turnstile</a>'
3423 - ));
3424 - echo '</p></div>';
3425 - } else {
3426 - echo '<div class="notice notice-success inline"><p>';
3427 - echo '✓ ' . esc_html__( 'Simple Cloudflare Turnstile plugin is installed and configured.', 'contact-forms' );
3428 - echo '</p></div>';
3429 - }
3430 - }
3431 - ?>
3432 - <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>
3433 - <ol style="max-width: 600px;">
3434 - <li><?php esc_html_e( 'Go to Forms → Edit Form', 'contact-forms');?></li>
3435 - <li><?php esc_html_e( 'Find "Turnstile" in the Fields sidebar', 'contact-forms');?></li>
3436 - <li><?php esc_html_e( 'Drag it into your form (typically before the Submit button)', 'contact-forms');?></li>
3437 - <li><?php esc_html_e( 'Save your form', 'contact-forms');?></li>
3438 - </ol>
3439 - <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>
3440 - </div></div>
3441 -
3442 - <div class="postbox">
3443 - <div class="postbox-header"><h2><?php esc_html_e( 'Track actions with Google Analytics and/or Matomo', 'contact-forms'); ?></h2></div>
3444 - <div class="inside">
2468 + <div class="postbox ">
2469 + <h3 class="hndle"><span><?php _e( 'IP address tracking', 'contact-forms'); ?></span></h3>
2470 + <div class="inside" id="dashboard_accua_form_anonymize_ip_addresses">
3445 2471 <p>
3446 - <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"'; } ?> />
3447 - <label for="accua_form_analytics_track_submit"><?php esc_html_e('Track submissions', 'contact-forms');?></label>
2472 + <?php _e("Select how many bytes of the visitor's IPs should be masked.", 'contact-forms');?>
3448 2473 </p>
3449 2474 <p>
3450 - <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"'; } ?> />
3451 - <label for="accua_form_analytics_track_fields"><?php esc_html_e('Track fields filled in', 'contact-forms');?></label>
3452 - </p>
3453 - </div></div>
3454 -
3455 - </div>
3456 - </div><!-- /panel: integrations -->
3457 -
3458 - <div class="accua-tabs__panel" role="tabpanel" data-tab="privacy">
3459 -
3460 - <div class="postbox">
3461 - <div class="postbox-header"><h2><?php esc_html_e( 'IP address tracking', 'contact-forms'); ?></h2></div>
3462 - <div class="inside">
3463 - <p>
3464 - <?php esc_html_e("Select how many bytes of the visitor's IPs should be masked.", 'contact-forms');?>
3465 - </p>
3466 - <p>
3467 2475 <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"'; } ?> />
3468 - <label for="anonymize_ip_bytes_0"><?php esc_html_e('No mask - e.g. 192.168.1.1', 'contact-forms');?></label><br />
2476 + <label for="anonymize_ip_bytes_0"><?php _e('No mask - e.g. 192.168.1.1', 'contact-forms');?></label><br />
3469 2477 </p>
3470 2478 <p>
3471 2479 <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"'; } ?> />
3472 - <label for="anonymize_ip_bytes_1"><?php esc_html_e('1 byte - e.g. 192.168.1.xxx', 'contact-forms');?></label><br />
2480 + <label for="anonymize_ip_bytes_1"><?php _e('1 byte - e.g. 192.168.1.xxx', 'contact-forms');?></label><br />
3473 2481 </p>
3474 2482 <p>
3475 2483 <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"'; } ?> />
3476 - <label for="anonymize_ip_bytes_2"><?php esc_html_e('2 byte - e.g. 192.168.xxx.xxx', 'contact-forms');?></label><br />
2484 + <label for="anonymize_ip_bytes_2"><?php _e('2 byte - e.g. 192.168.xxx.xxx', 'contact-forms');?></label><br />
3477 2485 </p>
3478 2486 <p>
3479 2487 <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"'; } ?> />
3480 - <label for="anonymize_ip_bytes_3"><?php esc_html_e('3 byte - e.g. 192.xxx.xxx.xxx', 'contact-forms');?></label><br />
2488 + <label for="anonymize_ip_bytes_3"><?php _e('3 byte - e.g. 192.xxx.xxx.xxx', 'contact-forms');?></label><br />
3481 2489 </p>
3482 2490 <p>
3483 2491 <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"'; } ?> />
3484 - <label for="anonymize_ip_bytes_4"><?php esc_html_e('Fully mask IP address', 'contact-forms');?></label><br />
2492 + <label for="anonymize_ip_bytes_4"><?php _e('Fully mask IP address', 'contact-forms');?></label><br />
3485 2493 </p>
3486 - <h4><?php esc_html_e( 'Delete IP addresses', 'contact-forms'); ?></h4>
2494 + <h4><?php _e( 'Delete IP addresses', 'contact-forms'); ?></h4>
3487 2495 <p>
3488 2496 <input type="checkbox" id="delete_previous_ip_values" name="delete_previous_ip_values" class="accua_form_value" value="1" />
3489 - <label for="delete_previous_ip_values"><?php esc_html_e('Delete all previous IP values', 'contact-forms');?></label><br />
2497 + <label for="delete_previous_ip_values"><?php _e('Delete all previous IP values', 'contact-forms');?></label><br />
3490 2498 </p>
3491 - </div></div>
2499 + <br clear="all">
2500 + </div>
2501 + </div>
3492 2502
3493 - <div class="postbox">
3494 - <div class="postbox-header"><h2><?php esc_html_e( 'Data retention', 'contact-forms'); ?></h2></div>
3495 - <div class="inside">
3496 - <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>
2503 + <div class="postbox ">
2504 + <h3 class="hndle"><span><?php _e( 'Track actions with Google Analytics', 'contact-forms'); ?></span></h3>
2505 + <div class="inside" id="dashboard_right_now">
3497 2506 <p>
3498 - <label for="retention_value"><?php esc_html_e( 'Retention period', 'contact-forms'); ?></label>
3499 - <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;" />
3500 - <select name="retention_unit" id="retention_unit">
3501 - <option value="days" <?php selected( $retention_data['retention_unit'], 'days' ); ?>><?php esc_html_e( 'days', 'contact-forms'); ?></option>
3502 - <option value="months" <?php selected( $retention_data['retention_unit'], 'months' ); ?>><?php esc_html_e( 'months', 'contact-forms'); ?></option>
3503 - <option value="years" <?php selected( $retention_data['retention_unit'], 'years' ); ?>><?php esc_html_e( 'years', 'contact-forms'); ?></option>
3504 - </select>
2507 + <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"'; } ?> />
2508 + <label for="accua_form_analytics_track_submit"><?php _e('Track submissions', 'contact-forms');?></label>
3505 2509 </p>
3506 2510 <p>
3507 - <strong><?php esc_html_e( 'When submissions expire:', 'contact-forms'); ?></strong><br />
3508 - <input type="radio" name="retention_mode" id="retention_mode_anonymize" value="anonymize" <?php checked( $retention_data['retention_mode'], 'anonymize' ); ?> />
3509 - <label for="retention_mode_anonymize"><?php esc_html_e( 'Anonymize — replace personal data with placeholders, keep submission record for statistics', 'contact-forms'); ?></label><br />
3510 - <input type="radio" name="retention_mode" id="retention_mode_delete" value="delete" <?php checked( $retention_data['retention_mode'], 'delete' ); ?> />
3511 - <label for="retention_mode_delete"><?php esc_html_e( 'Delete — permanently remove submission records from the database', 'contact-forms'); ?></label>
2511 + <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"'; } ?> />
2512 + <label for="accua_form_analytics_track_fields"><?php _e('Track fields filled in', 'contact-forms');?></label>
3512 2513 </p>
3513 - <p class="description"><?php esc_html_e( 'Individual forms can override this setting in the form editor.', 'contact-forms'); ?></p>
3514 - <p class="description"><?php
3515 - /* translators: %s: URL to the WordPress Erase Personal Data tool */
3516 - printf( esc_html__( 'To manually erase data for a specific person, use the WordPress %s tool.', 'contact-forms'),
3517 - '<a href="' . esc_url( admin_url( 'erase-personal-data.php' ) ) . '">' . esc_html__( 'Erase Personal Data', 'contact-forms') . '</a>'
3518 - );
3519 - ?></p>
3520 - </div></div>
2514 + </div>
2515 + </div>
3521 2516
3522 - </div><!-- /panel: privacy -->
2517 + </div>
3523 2518
3524 - <div class="accua-tabs__panel" role="tabpanel" data-tab="styling">
3525 - <div class="accua-settings-grid">
2519 + <div class="metabox-holder accua-forms-metabox-holder">
2520 + <div class="postbox ">
2521 + <h3 class="hndle"><span><?php _e( 'Layout &amp; Styling', 'contact-forms'); ?></span></h3>
2522 + <div class="inside" id="dashboard_right_now">
2523 + <p><?php _e( 'Customize the look and feel of your forms. Leave fields empty if you wish to use the native styles of your WordPress Theme.', 'contact-forms'); ?><p>
2524 + <h4><?php _e( 'Forms', 'contact-forms'); ?></h4>
2525 + <div id="accua_form_layout"> <?php _e( 'Layout', 'contact-forms'); ?>
2526 + <select name="layout" class="accua_form_value"><option value="sidebyside" <?php if ($form_data['layout'] == 'sidebyside') { echo 'selected="selected"'; } ?>>Labels on the left of the fields</option><option value="toplabel" <?php if ($form_data['layout'] == 'toplabel') { echo 'selected="selected"'; } ?>>Labels on top of the fields</option></select>
2527 + </div>
2528 + <div id="accua_form_style_margin" class="label_input">
2529 + <label><?php _e( 'Margin', 'contact-forms'); ?></label>
2530 + <input name="style_margin" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_margin'], ENT_QUOTES) ?>" />
2531 + </div>
2532 + <div id="accua_form_style_border_color" class="label_input">
2533 + <label><?php _e( 'Border color', 'contact-forms'); ?></label>
2534 + <input name="style_border_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_color'], ENT_QUOTES) ?>" />
2535 + </div>
2536 + <div id="accua_form_style_border_width" class="label_input">
2537 + <label><?php _e( 'Border width', 'contact-forms'); ?></label>
2538 + <input name="style_border_width" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_width'], ENT_QUOTES) ?>" />
2539 + </div>
2540 + <div id="accua_form_style_border_radius" class="label_input">
2541 + <label><?php _e( 'Rounded corner radius', 'contact-forms'); ?></label>
2542 + <input name="style_border_radius" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_radius'], ENT_QUOTES) ?>" />
2543 + </div>
2544 + <div id="accua_form_style_background_color" class="label_input">
2545 + <label><?php _e( 'Background color', 'contact-forms'); ?></label>
2546 + <input name="style_background_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_background_color'], ENT_QUOTES) ?>" />
2547 + </div>
2548 + <div id="accua_form_style_padding" class="label_input">
2549 + <label><?php _e( 'Padding', 'contact-forms'); ?></label>
2550 + <input name="style_padding" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_padding'], ENT_QUOTES) ?>" />
2551 + </div>
2552 + <div id="accua_form_style_color" class="label_input">
2553 + <label><?php _e( 'Text color', 'contact-forms'); ?></label>
2554 + <input name="style_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_color'], ENT_QUOTES) ?>" />
2555 + </div>
2556 + <div id="accua_form_style_font_size" class="label_input">
2557 + <label><?php _e( 'Font size', 'contact-forms'); ?></label>
2558 + <input name="style_font_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_font_size'], ENT_QUOTES) ?>" />
2559 + </div>
3526 2560
3527 - <div class="postbox">
3528 - <div class="postbox-header"><h2><?php esc_html_e( 'Form Container', 'contact-forms'); ?></h2></div>
3529 - <div class="inside">
3530 - <table class="form-table" role="presentation">
3531 - <tr>
3532 - <th scope="row"><label for="accua_form_layout_select"><?php esc_html_e( 'Layout', 'contact-forms'); ?></label></th>
3533 - <td>
3534 - <select id="accua_form_layout_select" name="layout" class="accua_form_value">
3535 - <option value="sidebyside" <?php selected( 'sidebyside', $form_data['layout'] ); ?>><?php echo esc_html( accua_forms_get_layout_label( 'sidebyside' ) ); ?></option>
3536 - <option value="toplabel" <?php selected( 'toplabel', $form_data['layout'] ); ?>><?php echo esc_html( accua_forms_get_layout_label( 'toplabel' ) ); ?></option>
3537 - <option value="inlinelabel" <?php selected( 'inlinelabel', $form_data['layout'] ); ?>><?php echo esc_html( accua_forms_get_layout_label( 'inlinelabel' ) ); ?></option>
3538 - </select>
3539 - <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>
3540 - </td>
3541 - </tr>
3542 - <tr>
3543 - <th scope="row"><label for="accua_style_margin"><?php esc_html_e( 'Margin', 'contact-forms'); ?></label></th>
3544 - <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>
3545 - </tr>
3546 - <tr>
3547 - <th scope="row"><label for="accua_style_border_color"><?php esc_html_e( 'Border color', 'contact-forms'); ?></label></th>
3548 - <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>
3549 - </tr>
3550 - <tr>
3551 - <th scope="row"><label for="accua_style_border_width"><?php esc_html_e( 'Border width', 'contact-forms'); ?></label></th>
3552 - <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>
3553 - </tr>
3554 - <tr>
3555 - <th scope="row"><label for="accua_style_border_radius"><?php esc_html_e( 'Rounded corner radius', 'contact-forms'); ?></label></th>
3556 - <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>
3557 - </tr>
3558 - <tr>
3559 - <th scope="row"><label for="accua_style_background_color"><?php esc_html_e( 'Background color', 'contact-forms'); ?></label></th>
3560 - <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>
3561 - </tr>
3562 - <tr>
3563 - <th scope="row"><label for="accua_style_padding"><?php esc_html_e( 'Padding', 'contact-forms'); ?></label></th>
3564 - <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>
3565 - </tr>
3566 - <tr>
3567 - <th scope="row"><label for="accua_style_color"><?php esc_html_e( 'Text color', 'contact-forms'); ?></label></th>
3568 - <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>
3569 - </tr>
3570 - <tr>
3571 - <th scope="row"><label for="accua_style_font_size"><?php esc_html_e( 'Font size', 'contact-forms'); ?></label></th>
3572 - <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>
3573 - </tr>
3574 - </table>
3575 - </div></div>
2561 + <h4><?php _e( 'Fields', 'contact-forms'); ?></h4>
2562 + <div id="accua_form_style_field_spacing" class="label_input">
2563 + <label><?php _e( 'Spacing', 'contact-forms'); ?></label>
2564 + <input name="style_field_spacing" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_spacing'], ENT_QUOTES) ?>" />
2565 + </div>
2566 + <div id="accua_form_style_field_border_color" class="label_input">
2567 + <label><?php _e( 'Border color', 'contact-forms'); ?></label>
2568 + <input name="style_field_border_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_color'], ENT_QUOTES) ?>" />
2569 + </div>
2570 + <div id="accua_form_style_field_border_width" class="label_input">
2571 + <label><?php _e( 'Border width', 'contact-forms'); ?></label>
2572 + <input name="style_field_border_width" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_width'], ENT_QUOTES) ?>" />
2573 + </div>
2574 + <div id="accua_form_style_field_border_radius" class="label_input">
2575 + <label><?php _e( 'Rounded corner radius', 'contact-forms'); ?></label>
2576 + <input name="style_field_border_radius" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_radius'], ENT_QUOTES) ?>" />
2577 + </div>
2578 + <div id="accua_form_style_field_background_color" class="label_input">
2579 + <label><?php _e( 'Background color', 'contact-forms'); ?></label>
2580 + <input name="style_field_background_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_background_color'], ENT_QUOTES) ?>" />
2581 + </div>
2582 + <div id="accua_form_style_field_padding" class="label_input">
2583 + <label><?php _e( 'Padding', 'contact-forms'); ?></label>
2584 + <input name="style_field_padding" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_padding'], ENT_QUOTES) ?>" />
2585 + </div>
2586 + <div id="accua_form_style_field_color" class="label_input">
2587 + <label><?php _e( 'Text color', 'contact-forms'); ?></label>
2588 + <input name="style_field_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_color'], ENT_QUOTES) ?>" />
2589 + </div>
3576 2590
3577 - <div class="postbox">
3578 - <div class="postbox-header"><h2><?php esc_html_e( 'Fields', 'contact-forms'); ?></h2></div>
3579 - <div class="inside">
3580 - <table class="form-table" role="presentation">
3581 - <tr>
3582 - <th scope="row"><label for="accua_style_field_spacing"><?php esc_html_e( 'Spacing', 'contact-forms'); ?></label></th>
3583 - <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>
3584 - </tr>
3585 - <tr>
3586 - <th scope="row"><label for="accua_style_field_border_color"><?php esc_html_e( 'Border color', 'contact-forms'); ?></label></th>
3587 - <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>
3588 - </tr>
3589 - <tr>
3590 - <th scope="row"><label for="accua_style_field_border_width"><?php esc_html_e( 'Border width', 'contact-forms'); ?></label></th>
3591 - <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>
3592 - </tr>
3593 - <tr>
3594 - <th scope="row"><label for="accua_style_field_border_radius"><?php esc_html_e( 'Rounded corner radius', 'contact-forms'); ?></label></th>
3595 - <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>
3596 - </tr>
3597 - <tr>
3598 - <th scope="row"><label for="accua_style_field_background_color"><?php esc_html_e( 'Background color', 'contact-forms'); ?></label></th>
3599 - <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>
3600 - </tr>
3601 - <tr>
3602 - <th scope="row"><label for="accua_style_field_padding"><?php esc_html_e( 'Padding', 'contact-forms'); ?></label></th>
3603 - <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>
3604 - </tr>
3605 - <tr>
3606 - <th scope="row"><label for="accua_style_field_color"><?php esc_html_e( 'Text color', 'contact-forms'); ?></label></th>
3607 - <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>
3608 - </tr>
3609 - </table>
3610 - </div></div>
2591 + <h4><?php _e( 'Submit button', 'contact-forms'); ?></h4>
2592 + <div id="accua_form_style_submit_border_color" class="label_input">
2593 + <label><?php _e( 'Border color', 'contact-forms'); ?></label>
2594 + <input name="style_submit_border_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_color'], ENT_QUOTES) ?>" />
2595 + </div>
2596 + <div id="accua_form_style_submit_border_width" class="label_input">
2597 + <label><?php _e( 'Border width', 'contact-forms'); ?></label>
2598 + <input name="style_submit_border_width" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_width'], ENT_QUOTES) ?>" />
2599 + </div>
2600 + <div id="accua_form_style_submit_border_radius" class="label_input">
2601 + <label><?php _e( 'Rounded corner radius', 'contact-forms'); ?></label>
2602 + <input name="style_submit_border_radius" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_radius'], ENT_QUOTES) ?>" />
2603 + </div>
2604 + <div id="accua_form_style_submit_background_color" class="label_input">
2605 + <label><?php _e( 'Background color', 'contact-forms'); ?></label>
2606 + <input name="style_submit_background_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_background_color'], ENT_QUOTES) ?>" />
2607 + </div>
2608 + <div id="accua_form_style_submit_padding" class="label_input">
2609 + <label><?php _e( 'Padding', 'contact-forms'); ?></label>
2610 + <input name="style_submit_padding" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_padding'], ENT_QUOTES) ?>" />
2611 + </div>
2612 + <div id="accua_form_style_submit_color" class="label_input">
2613 + <label><?php _e( 'Text color', 'contact-forms'); ?></label>
2614 + <input name="style_submit_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_color'], ENT_QUOTES) ?>" />
2615 + </div>
2616 + <div id="accua_form_style_submit_font_size" class="label_input">
2617 + <label><?php _e( 'Font size', 'contact-forms'); ?></label>
2618 + <input name="style_submit_font_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_font_size'], ENT_QUOTES) ?>" />
2619 + </div>
2620 + <br clear="all" />
2621 + </div>
2622 + </div>
2623 + </div>
3611 2624
3612 - <div class="postbox">
3613 - <div class="postbox-header"><h2><?php esc_html_e( 'Submit Button', 'contact-forms'); ?></h2></div>
3614 - <div class="inside">
3615 - <table class="form-table" role="presentation">
3616 - <tr>
3617 - <th scope="row"><label for="accua_style_submit_border_color"><?php esc_html_e( 'Border color', 'contact-forms'); ?></label></th>
3618 - <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>
3619 - </tr>
3620 - <tr>
3621 - <th scope="row"><label for="accua_style_submit_border_width"><?php esc_html_e( 'Border width', 'contact-forms'); ?></label></th>
3622 - <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>
3623 - </tr>
3624 - <tr>
3625 - <th scope="row"><label for="accua_style_submit_border_radius"><?php esc_html_e( 'Rounded corner radius', 'contact-forms'); ?></label></th>
3626 - <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>
3627 - </tr>
3628 - <tr>
3629 - <th scope="row"><label for="accua_style_submit_background_color"><?php esc_html_e( 'Background color', 'contact-forms'); ?></label></th>
3630 - <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>
3631 - </tr>
3632 - <tr>
3633 - <th scope="row"><label for="accua_style_submit_padding"><?php esc_html_e( 'Padding', 'contact-forms'); ?></label></th>
3634 - <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>
3635 - </tr>
3636 - <tr>
3637 - <th scope="row"><label for="accua_style_submit_color"><?php esc_html_e( 'Text color', 'contact-forms'); ?></label></th>
3638 - <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>
3639 - </tr>
3640 - <tr>
3641 - <th scope="row"><label for="accua_style_submit_font_size"><?php esc_html_e( 'Font size', 'contact-forms'); ?></label></th>
3642 - <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>
3643 - </tr>
3644 - </table>
3645 - </div></div>
3646 2625
3647 - </div>
3648 - </div><!-- /panel: styling -->
2626 + <br clear="all"/>
3649 2627
3650 - <?php if ( current_user_can( 'manage_options' ) ) : ?>
3651 - <div class="accua-tabs__panel" role="tabpanel" data-tab="danger_zone">
2628 +</div>
3652 2629
3653 - <div class="postbox accua-danger-zone">
3654 - <div class="postbox-header"><h2><?php esc_html_e( 'Anonymize old submissions', 'contact-forms' ); ?></h2></div>
3655 - <div class="inside">
3656 - <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>
3657 - <p>
3658 - <input type="number" id="accua_danger_anon_value" min="1" step="1" value="12" style="width: 80px;" />
3659 - <select id="accua_danger_anon_unit" style="vertical-align: baseline;">
3660 - <option value="days"><?php esc_html_e( 'days', 'contact-forms' ); ?></option>
3661 - <option value="months" selected><?php esc_html_e( 'months', 'contact-forms' ); ?></option>
3662 - <option value="years"><?php esc_html_e( 'years', 'contact-forms' ); ?></option>
3663 - </select>
3664 - <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>
3665 - </p>
3666 - <div id="accua_danger_anon_result" style="display:none;"></div>
3667 - </div></div>
3668 -
3669 - <div class="postbox accua-danger-zone">
3670 - <div class="postbox-header"><h2><?php esc_html_e( 'Delete all Contact Forms data', 'contact-forms' ); ?></h2></div>
3671 - <div class="inside">
3672 - <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>
3673 - <p>
3674 - <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>
3675 - </p>
3676 - <div id="accua_danger_delete_result" style="display:none;"></div>
3677 - </div></div>
3678 -
3679 - </div><!-- /panel: danger_zone -->
3680 - <?php endif; ?>
3681 -
3682 - <div class="accua-tabs__panel" role="tabpanel" data-tab="tokens">
3683 - <?php accua_forms_print_tokens(); ?>
3684 - </div><!-- /panel: tokens -->
3685 -
3686 - <div class="accua-tabs__panel" role="tabpanel" data-tab="theme_helper">
3687 - <?php accua_forms_theme_helper_content(); ?>
3688 - </div><!-- /panel: theme_helper -->
3689 -
3690 -</div><!-- /accua_settings_tabs -->
3691 -
3692 2630 <?php /*
3693 2631 <h3><?php _e( 'File upload default settings', 'contact-forms'); ?></h3>
3694 2632 <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>
3695 2633 <small><?php _e( 'List of valid extensions, without dot, one per line.', 'contact-forms'); ?></small>
@@ -3709,28 +2647,24 @@
3709 2647 <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>
3710 2648 </p> */ ?>
3711 2649 <p><input class="button button-primary button-large" id="accua_form_save_settings" type="submit" value="Save settings" /></p>
3712 2650
2651 +<?php accua_forms_print_tokens(); ?>
2652 +
3713 2653 </form>
3714 -
3715 -<span id="accua-forms-version"><?php
3716 - $plugin_data = get_plugin_data( ACCUA_FORMS_FILE );
3717 - echo esc_html( $plugin_data['Name'] ); ?> &mdash; <a href="https://www.cimatti.it/en/wordpress-plugins/contact-forms/"><?php
3718 - esc_html_e('Version', 'contact-forms'); echo ' ' . esc_html( $plugin_data['Version'] ); ?></a></span>
3719 -
3720 2654 </div>
3721 2655
3722 2656 <script type='text/javascript'>
3723 2657 jQuery(function($) {
3724 - $('#accua_form_style_border_color .accua_form_value').wpColorPicker();
3725 - $('#accua_form_style_background_color .accua_form_value').wpColorPicker();
3726 - $('#accua_form_style_color .accua_form_value').wpColorPicker();
3727 - $('#accua_form_style_field_border_color .accua_form_value').wpColorPicker();
3728 - $('#accua_form_style_field_background_color .accua_form_value').wpColorPicker();
3729 - $('#accua_form_style_field_color .accua_form_value').wpColorPicker();
3730 - $('#accua_form_style_submit_border_color .accua_form_value').wpColorPicker();
3731 - $('#accua_form_style_submit_background_color .accua_form_value').wpColorPicker();
3732 - $('#accua_form_style_submit_color .accua_form_value').wpColorPicker();
2658 + $('#accua_form_style_border_color .accua_form_value').colorPicker();
2659 + $('#accua_form_style_background_color .accua_form_value').colorPicker();
2660 + $('#accua_form_style_color .accua_form_value').colorPicker();
2661 + $('#accua_form_style_field_border_color .accua_form_value').colorPicker();
2662 + $('#accua_form_style_field_background_color .accua_form_value').colorPicker();
2663 + $('#accua_form_style_field_color .accua_form_value').colorPicker();
2664 + $('#accua_form_style_submit_border_color .accua_form_value').colorPicker();
2665 + $('#accua_form_style_submit_background_color .accua_form_value').colorPicker();
2666 + $('#accua_form_style_submit_color .accua_form_value').colorPicker();
3733 2667 });
3734 2668 </script>
3735 2669
3736 2670 <?php
@@ -3735,13 +2669,12 @@
3735 2669
3736 2670 <?php
3737 2671 }
3738 2672
3739 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function, underscore prefix indicates private
3740 2673 function _accua_forms_get_abs_dest_path($dest_path = '') {
3741 2674 if ($dest_path === '') {
3742 2675 return realpath(ABSPATH) . '/wp-content/uploads/accua-forms';
3743 - } elseif (substr($dest_path,0,1) === '/') {
2676 + } else if (substr($dest_path,0,1) === '/') {
3744 2677 return $dest_path;
3745 2678 } else {
3746 2679 return realpath(ABSPATH) . '/' . $dest_path;
3747 2680 }
@@ -3746,9 +2679,8 @@
3746 2679 return realpath(ABSPATH) . '/' . $dest_path;
3747 2680 }
3748 2681 }
3749 2682
3750 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function, underscore prefix indicates private
3751 2683 function _accua_forms_get_form_data($fid = false, $return_empty = true, $restore_trash = false){
3752 2684 $empty_form_data = array(
3753 2685 'fields' => array(),
3754 2686 'title' => '',
@@ -3762,9 +2694,8 @@
3762 2694 'admin_emails_message' => '',
3763 2695 'confirmation_emails_subject' => '',
3764 2696 'confirmation_emails_message' => '',
3765 2697 'use_ajax' => true,
3766 - 'gads_conversion_tracking_code' => '',
3767 2698 'layout' => 'sidebyside',
3768 2699 'style_margin' => '',
3769 2700 'style_border_color' => '',
3770 2701 'style_border_width' => '',
@@ -3786,12 +2717,8 @@
3786 2717 'style_submit_background_color' => '',
3787 2718 'style_submit_padding' => '',
3788 2719 'style_submit_color' => '',
3789 2720 'style_submit_font_size' => '',
3790 - 'submission_retention_override' => false,
3791 - 'submission_retention_value' => 0,
3792 - 'submission_retention_unit' => 'months',
3793 - 'submission_retention_mode' => 'anonymize',
3794 2721 );
3795 2722
3796 2723 if ($fid === false) {
3797 2724 return $empty_form_data;
@@ -3825,9 +2752,9 @@
3825 2752 }
3826 2753 }
3827 2754 */
3828 2755 return $form_data;
3829 - } elseif ($return_empty) {
2756 + } else if ($return_empty) {
3830 2757 return array(
3831 2758 '_overrided' => array()
3832 2759 ) + $default_form_data + $empty_form_data;
3833 2760 } else {
@@ -3835,174 +2762,8 @@
3835 2762 }
3836 2763
3837 2764 }
3838 2765
3839 -/**
3840 - * Draft System Functions
3841 - *
3842 - * The draft system allows users to make changes to forms in the admin editor
3843 - * without immediately affecting the live/published form. Changes are stored in
3844 - * a transient until the user clicks Save, which publishes the draft.
3845 - *
3846 - * Pattern follows WordPress auto-draft system.
3847 - */
3848 -
3849 -/**
3850 - * Get the transient key for a form's draft data.
3851 - *
3852 - * @param string|int $fid Form ID.
3853 - * @return string Transient key.
3854 - */
3855 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function
3856 -function _accua_forms_get_draft_key( $fid ) {
3857 - return 'accua_forms_draft_' . $fid;
3858 -}
3859 -
3860 -/**
3861 - * Initialize or get existing draft for a form.
3862 - * Called when the form editor is loaded.
3863 - *
3864 - * If a draft exists, returns it.
3865 - * If no draft exists, creates one from published data.
3866 - *
3867 - * @param string|int $fid Form ID.
3868 - * @return array Draft data array.
3869 - */
3870 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function
3871 -function _accua_forms_init_draft( $fid ) {
3872 - $draft_key = _accua_forms_get_draft_key( $fid );
3873 -
3874 - // Check for existing draft
3875 - $draft_data = get_transient( $draft_key );
3876 -
3877 - if ( $draft_data !== false ) {
3878 - // Draft exists - return it
3879 - return $draft_data;
3880 - }
3881 -
3882 - // No draft - create from published data
3883 - $forms_data = get_option( 'accua_forms_saved_forms', array() );
3884 -
3885 - if ( isset( $forms_data[ $fid ] ) ) {
3886 - $draft_data = $forms_data[ $fid ];
3887 - } else {
3888 - // New form - initialize empty structure
3889 - $draft_data = array( 'fields' => array() );
3890 - }
3891 -
3892 - // Store as draft with 24 hour expiry
3893 - set_transient( $draft_key, $draft_data, DAY_IN_SECONDS );
3894 -
3895 - return $draft_data;
3896 -}
3897 -
3898 -/**
3899 - * Get draft data for a form (creating if necessary).
3900 - * Used by AJAX handlers to read current draft state.
3901 - *
3902 - * @param string|int $fid Form ID.
3903 - * @return array Draft data array.
3904 - */
3905 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function
3906 -function _accua_forms_get_draft_data( $fid ) {
3907 - $draft_key = _accua_forms_get_draft_key( $fid );
3908 - $draft_data = get_transient( $draft_key );
3909 -
3910 - if ( $draft_data === false ) {
3911 - // Initialize draft from published data
3912 - $draft_data = _accua_forms_init_draft( $fid );
3913 - }
3914 -
3915 - return $draft_data;
3916 -}
3917 -
3918 -/**
3919 - * Save data to draft transient.
3920 - * Called by AJAX handlers when fields are edited.
3921 - *
3922 - * @param string|int $fid Form ID.
3923 - * @param array $draft_data Complete draft data to save.
3924 - * @return bool True on success.
3925 - */
3926 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function
3927 -function _accua_forms_save_draft( $fid, $draft_data ) {
3928 - $draft_key = _accua_forms_get_draft_key( $fid );
3929 - return set_transient( $draft_key, $draft_data, DAY_IN_SECONDS );
3930 -}
3931 -
3932 -/**
3933 - * Publish draft to live data.
3934 - * Called when user clicks Save button.
3935 - *
3936 - * @param string|int $fid Form ID.
3937 - * @return bool True on success.
3938 - */
3939 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function
3940 -function _accua_forms_publish_draft( $fid ) {
3941 - $draft_key = _accua_forms_get_draft_key( $fid );
3942 - $draft_data = get_transient( $draft_key );
3943 -
3944 - if ( $draft_data === false ) {
3945 - // No draft to publish - shouldn't happen normally
3946 - return false;
3947 - }
3948 -
3949 - // Get current published data
3950 - $forms_data = get_option( 'accua_forms_saved_forms', array() );
3951 -
3952 - // Update with draft
3953 - $forms_data[ $fid ] = $draft_data;
3954 -
3955 - // Save to database
3956 - $result = update_option( 'accua_forms_saved_forms', $forms_data );
3957 -
3958 - if ( $result ) {
3959 - // Clear draft after successful publish
3960 - delete_transient( $draft_key );
3961 - }
3962 -
3963 - return $result;
3964 -}
3965 -
3966 -/**
3967 - * Delete draft for a form.
3968 - * Called when discarding changes or after successful publish.
3969 - *
3970 - * @param string|int $fid Form ID.
3971 - * @return bool True on success.
3972 - */
3973 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function
3974 -function _accua_forms_delete_draft( $fid ) {
3975 - $draft_key = _accua_forms_get_draft_key( $fid );
3976 - return delete_transient( $draft_key );
3977 -}
3978 -
3979 -/**
3980 - * Check if a draft exists and differs from published data.
3981 - * Used to show "unsaved changes" warning.
3982 - *
3983 - * @param string|int $fid Form ID.
3984 - * @return bool True if draft exists and differs from published.
3985 - */
3986 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function
3987 -function _accua_forms_has_unsaved_draft( $fid ) {
3988 - $draft_key = _accua_forms_get_draft_key( $fid );
3989 - $draft_data = get_transient( $draft_key );
3990 -
3991 - if ( $draft_data === false ) {
3992 - return false;
3993 - }
3994 -
3995 - // Compare with published data
3996 - $forms_data = get_option( 'accua_forms_saved_forms', array() );
3997 - $published_data = isset( $forms_data[ $fid ] ) ? $forms_data[ $fid ] : array();
3998 -
3999 - // Deep comparison (serialize for simplicity)
4000 - // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Used for comparison only
4001 - return serialize( $draft_data ) !== serialize( $published_data );
4002 -}
4003 -
4004 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function, underscore prefix indicates private
4005 2766 function _accua_forms_style_parameters($params) {
4006 2767 $ret = '';
4007 2768 foreach ($params as $key => $value) {
4008 2769 $value = trim($value);
@@ -4026,23 +2787,9 @@
4026 2787 add_action('accua_form_alter', 'accua_forms_form_generate', -999, 2);
4027 2788 function accua_forms_form_generate($baseid, $form) {
4028 2789 if (substr($baseid, 0, 14) == '__accua-form__') {
4029 2790 $fid = substr($baseid,14);
4030 -
4031 - // Check if we're in admin preview mode - if so, read from draft
4032 - $use_draft = apply_filters('accua_forms_use_draft_for_preview', false);
4033 - if ($use_draft) {
4034 - // Get draft data and merge with defaults
4035 - $draft_data = _accua_forms_get_draft_data($fid);
4036 - $default_form_data = get_option('accua_forms_default_form_data', array());
4037 - $empty_form_data = _accua_forms_get_form_data(false); // Get empty structure
4038 - $form_data = array(
4039 - '_overrided' => $draft_data
4040 - ) + $draft_data + $default_form_data + $empty_form_data;
4041 - } else {
4042 - // Frontend: read from published data
4043 - $form_data = _accua_forms_get_form_data($fid, false);
4044 - }
2791 + $form_data = _accua_forms_get_form_data($fid, false);
4045 2792 /*
4046 2793 echo '<!-- fid = ';
4047 2794 print_r($fid);
4048 2795 echo "\n\nform_data = ";
@@ -4049,45 +2796,14 @@
4049 2796 print_r($form_data);
4050 2797 echo "\n-->";
4051 2798 */
4052 2799 if ($form_data) {
4053 - // Check for preview order override (allows live preview of field reorder before save)
4054 - $preview_order_override = apply_filters('accua_forms_preview_order_override', null);
4055 - if ($preview_order_override && !empty($form_data['fields'])) {
4056 - // Find the sidebar key for this form (format: cimatti-accua-fields-form-area-{fid})
4057 - $sidebar_key = 'cimatti-accua-fields-form-area-' . $fid;
4058 - if (isset($preview_order_override[$sidebar_key])) {
4059 - $order_string = $preview_order_override[$sidebar_key];
4060 - $order_array = explode(',', $order_string);
4061 -
4062 - // Reorder fields according to preview order
4063 - $old_fields = $form_data['fields'];
4064 - $new_fields = array();;
4065 -
4066 - foreach ($order_array as $widget_id) {
4067 - // Extract instance ID from widget ID (format: widget-{type}_{instance_id})
4068 - $instance_id = preg_replace('/^(new-)?widget-\\d+_/', '', $widget_id);
4069 - if (isset($old_fields[$instance_id])) {
4070 - $new_fields[$instance_id] = $old_fields[$instance_id];
4071 - unset($old_fields[$instance_id]);
4072 - }
4073 - }
4074 -
4075 - // Append any remaining fields not in order
4076 - if ($old_fields) {
4077 - $new_fields += $old_fields;
4078 - }
4079 -
4080 - $form_data['fields'] = $new_fields;
4081 - }
4082 - }
4083 -
4084 2800 $form_style = _accua_forms_style_parameters(array(
4085 2801 'margin' => $form_data['style_margin'],
4086 2802 'border-color' => $form_data['style_border_color'],
4087 2803 'border-width' => $form_data['style_border_width'],
4088 2804 'border-radius' => $form_data['style_border_radius'],
4089 - 'background-color' => $form_data['style_background_color'],
2805 + 'background' => $form_data['style_background_color'],
4090 2806 'padding' => $form_data['style_padding'],
4091 2807 'color' => $form_data['style_color'],
4092 2808 'font-size' => $form_data['style_font_size'],
4093 2809 ));
@@ -4096,9 +2812,9 @@
4096 2812 'margin-bottom' => $form_data['style_field_spacing'],
4097 2813 'border-color' => $form_data['style_field_border_color'],
4098 2814 'border-width' => $form_data['style_field_border_width'],
4099 2815 'border-radius' => $form_data['style_field_border_radius'],
4100 - 'background-color' => $form_data['style_field_background_color'],
2816 + 'background' => (trim($form_data['style_field_background_color']) === '')?'transparent':$form_data['style_field_background_color'],
4101 2817 'padding' => $form_data['style_field_padding'],
4102 2818 'color' => (trim($form_data['style_field_color']) === '')?$form_data['style_color']:$form_data['style_field_color'],
4103 2819 'font-size' => $form_data['style_font_size'],
4104 2820 ));
@@ -4105,17 +2821,14 @@
4105 2821 $field_properties = array();
4106 2822 if ($field_style !== '') {
4107 2823 $field_properties['style'] = $field_style;
4108 2824 }
4109 - // These will be set per-field in the loop below, initialized empty here
4110 - $field_properties['wrapperCssClass'] = '';
4111 - $field_properties['wrapperCssId'] = '';
4112 2825
4113 2826 $submit_style = _accua_forms_style_parameters(array(
4114 2827 'border-color' => $form_data['style_submit_border_color'],
4115 2828 'border-width' => $form_data['style_submit_border_width'],
4116 2829 'border-radius' => $form_data['style_submit_border_radius'],
4117 - 'background-color' => $form_data['style_submit_background_color'],
2830 + 'background' => $form_data['style_submit_background_color'],
4118 2831 'padding' => $form_data['style_submit_padding'],
4119 2832 'color' => $form_data['style_submit_color'],
4120 2833 'font-size' => $form_data['style_submit_font_size'],
4121 2834 ));
@@ -4148,9 +2861,9 @@
4148 2861 'name' => __('Fieldset begin', 'contact-forms'),
4149 2862 'type' => 'fieldset-begin',
4150 2863 'description' => '',
4151 2864 );
4152 - } elseif ($istance_data['ref'] == '__fieldset-end') {
2865 + } else if ($istance_data['ref'] == '__fieldset-end') {
4153 2866 $field_data = array(
4154 2867 'id' => '__fieldset-end',
4155 2868 'name' => __('Fieldset end', 'contact-forms'),
4156 2869 'type' => 'fieldset-end',
@@ -4170,10 +2883,8 @@
4170 2883 'description' => __('Use this special field to inject raw HTML in the form. You can use this multiple times.', 'contact-forms'),
4171 2884 'default_value' => '',
4172 2885 'allowed_values' => '',
4173 2886 'allowed_extensions' => '',
4174 - 'custom_required_message' => '',
4175 - 'custom_format_message' => '',
4176 2887 );
4177 2888
4178 2889 $istance_data += array(
4179 2890 'version' => 1,
@@ -4207,13 +2918,8 @@
4207 2918 'label' => $field_data['name'],
4208 2919 'default_value' => $field_data['default_value'], /* viene impostato il valore di defualt se non è un campo data */
4209 2920 'allowed_values' => $field_data['allowed_values'],
4210 2921 'allowed_extensions' => $field_data['allowed_extensions'],
4211 - 'post_type' => 'page', // Default for post-select fields
4212 - 'css_class' => '',
4213 - 'css_id' => '',
4214 - 'custom_required_message' => '',
4215 - 'custom_format_message' => '',
4216 2922 );
4217 2923
4218 2924 $element = NULL;
4219 2925 $element_conf = NULL;
@@ -4219,26 +2925,15 @@
4219 2925 $element_conf = NULL;
4220 2926
4221 2927 $allowed_val = trim($istance_data['allowed_values']);
4222 2928
4223 - // For post-select fields, we use lazy loading via AJAX, so don't pre-load posts here
4224 - if ($field_data['type'] == 'post-multicheckbox') {
4225 - // Post-multicheckbox still needs pre-loaded options for checkbox rendering
4226 - $post_type = isset($istance_data['post_type']) ? $istance_data['post_type'] : 'page';
4227 - $query_args = $allowed_val;
4228 - if (!empty($query_args)) {
4229 - $query_args .= '&post_type=' . $post_type;
4230 - } else {
4231 - $query_args = 'post_type=' . $post_type;
4232 - }
4233 - $posts = accua_get_pages($query_args);
2929 + if ($field_data['type'] == 'post-multicheckbox' || $field_data['type'] == 'post-select') {
2930 + $posts = accua_get_pages($allowed_val);
4234 2931 $allowed_values = array();
4235 2932 foreach ($posts as $p) {
2933 + //$allowed_values[$p->ID] = apply_filters( 'the_title', $p->post_title, $p->ID );
4236 2934 $allowed_values[$p->ID] = $p->post_title;
4237 2935 }
4238 - } elseif ($field_data['type'] == 'post-select') {
4239 - // Post-select uses lazy loading - just set empty options, JS will fetch
4240 - $allowed_values = array();
4241 2936 } else {
4242 2937 if ($field_data['type'] == 'file') {
4243 2938 $filedata = get_option('accua_forms_default_file_field_data',array());
4244 2939 $filedata += array(
@@ -4272,37 +2967,8 @@
4272 2967 $allowed_values[$val[0]] = $val[1];
4273 2968 }
4274 2969 }
4275 2970
4276 - // Set per-field wrapper CSS class and ID
4277 - $field_properties['wrapperCssClass'] = isset($istance_data['css_class']) ? $istance_data['css_class'] : '';
4278 - $field_properties['wrapperCssId'] = isset($istance_data['css_id']) ? $istance_data['css_id'] : '';
4279 -
4280 - // Resolve per-field custom validation messages (per-form instance → field definition → default)
4281 - $resolved_required_msg = '';
4282 - if (!empty($istance_data['custom_required_message'])) {
4283 - $resolved_required_msg = $istance_data['custom_required_message'];
4284 - } elseif (!empty($field_data['custom_required_message'])) {
4285 - $resolved_required_msg = $field_data['custom_required_message'];
4286 - }
4287 -
4288 - $resolved_format_msg = '';
4289 - if (!empty($istance_data['custom_format_message'])) {
4290 - $resolved_format_msg = $istance_data['custom_format_message'];
4291 - } elseif (!empty($field_data['custom_format_message'])) {
4292 - $resolved_format_msg = $field_data['custom_format_message'];
4293 - }
4294 -
4295 - // Add data attributes for client-side custom messages (reset each iteration)
4296 - unset($field_properties['data-custom-required-msg']);
4297 - unset($field_properties['data-custom-format-msg']);
4298 - if ($resolved_required_msg !== '') {
4299 - $field_properties['data-custom-required-msg'] = $resolved_required_msg;
4300 - }
4301 - if ($resolved_format_msg !== '') {
4302 - $field_properties['data-custom-format-msg'] = $resolved_format_msg;
4303 - }
4304 -
4305 2971 switch ($field_data['type']) {
4306 2972 case 'textarea':
4307 2973 $element = new Element_Textarea($istance_data['label'], $istance_data['istance_id'], $field_properties+array('cols' => '50', 'value'=>$istance_data['default_value']));
4308 2974 break;
@@ -4317,17 +2983,18 @@
4317 2983 if ($allowed_values) {
4318 2984 reset($allowed_values);
4319 2985 $val = (string) key($allowed_values);
4320 2986 $defval = trim($istance_data['default_value']);
4321 - } elseif ($istance_data['default_value'] == '1') {
2987 + } else if ($istance_data['default_value'] == '1') {
4322 2988 $defval = $val = '1';
4323 2989 } else {
4324 2990 $val = empty($istance_data['default_value'])?'1':$istance_data['default_value'];
4325 2991 $defval = '';
4326 2992 }
4327 - $element = new AccuaForm_Element_Checkbox('', $istance_data['istance_id'], array($val => $lab), $field_properties+array('value' => $defval));
2993 + $element = new AccuaForm_Element_Checkbox('', $istance_data['istance_id'], array($val => $lab), array('value' => $defval));
4328 2994 break;
4329 2995 case 'select':
2996 + case 'post-select':
4330 2997 if (!isset($allowed_values[''])) {
4331 2998 $allowed_values = array('' => '') + $allowed_values;
4332 2999 }
4333 3000 $defval = trim($istance_data['default_value']);
@@ -4332,17 +2999,11 @@
4332 2999 }
4333 3000 $defval = trim($istance_data['default_value']);
4334 3001 $element = new AccuaForm_Element_Select($istance_data['label'], $istance_data['istance_id'], $allowed_values, $field_properties+array('value'=>$defval));
4335 3002 break;
4336 - case 'post-select':
4337 - $post_type = isset($istance_data['post_type']) ? $istance_data['post_type'] : 'page';
4338 - $extra_args = trim($istance_data['allowed_values']);
4339 - $defval = trim($istance_data['default_value']);
4340 - $element = new AccuaForm_Element_PostSelect($istance_data['label'], $istance_data['istance_id'], $post_type, $extra_args, $field_properties+array('value'=>$defval));
4341 - break;
4342 3003 case 'radio':
4343 3004 $defval = trim($istance_data['default_value']);
4344 - $element = new AccuaForm_Element_Radio($istance_data['label'], $istance_data['istance_id'], $allowed_values, $field_properties+array('value'=>$defval));
3005 + $element = new AccuaForm_Element_Radio($istance_data['label'], $istance_data['istance_id'], $allowed_values, array('value'=>$defval));
4345 3006 break;
4346 3007 case 'multiselect':
4347 3008 $defval = explode('|', $istance_data['default_value']);
4348 3009 foreach ($defval as $k => $v) {
@@ -4355,9 +3016,9 @@
4355 3016 $defval = explode('|', $istance_data['default_value']);
4356 3017 foreach ($defval as $k => $v) {
4357 3018 $defval[$k] = trim($v);
4358 3019 }
4359 - $element = new AccuaForm_Element_Checkbox($istance_data['label'], $istance_data['istance_id'], $allowed_values, $field_properties+array('value'=>$defval));
3020 + $element = new AccuaForm_Element_Checkbox($istance_data['label'], $istance_data['istance_id'], $allowed_values, array('value'=>$defval));
4360 3021 break;
4361 3022 case 'file':
4362 3023 $fdata = array();
4363 3024
@@ -4373,17 +3034,17 @@
4373 3034
4374 3035 $element = new AccuaForm_Element_File($istance_data['label'], $istance_data['istance_id'], $field_properties+$fdata);
4375 3036 break;
4376 3037 case 'html':
4377 - $element = new Element_HTML($istance_data['default_value'], $field_properties);
3038 + $element = new Element_HTML($istance_data['default_value']);
4378 3039 break;
4379 3040 case 'email':
4380 3041 case 'autoreply_email':
4381 - $email_props = $field_properties+array('value'=>$istance_data['default_value']);
4382 - if ($resolved_format_msg !== '') {
4383 - $email_props['custom_format_message'] = $resolved_format_msg;
4384 - }
4385 - $element = new AccuaForm_Element_Email($istance_data['label'], $istance_data['istance_id'], $email_props);
3042 + $element = new AccuaForm_Element_Email($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value']));
3043 + $element->setValidation(new Validation_Email(
3044 + str_replace('%element%', $istance_data['label'], __("Attention: '%element%' must contain an email address.", 'contact-forms'))
3045 + ));
3046 + //"Errore: '{$istance_data['label']}' deve contenere un indirizzo email valido."
4386 3047 break;
4387 3048 case 'colorpicker':
4388 3049 $element = new AccuaForm_Element_ColorPicker($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value']));
4389 3050 break;
@@ -4392,9 +3053,9 @@
4392 3053 $form->addElement(new AccuaForm_Element_FieldsetEnd());
4393 3054 } else {
4394 3055 $fieldset_open = true;
4395 3056 }
4396 - $element = new AccuaForm_Element_FieldsetBegin($istance_data['label'], $istance_data['istance_id'], $field_properties);
3057 + $element = new AccuaForm_Element_FieldsetBegin($istance_data['label'], $istance_data['istance_id']);
4397 3058 break;
4398 3059 case 'fieldset-end':
4399 3060 if ($fieldset_open) {
4400 3061 $element = new AccuaForm_Element_FieldsetEnd();
@@ -4421,20 +3082,17 @@
4421 3082 }
4422 3083 if ($captcha_use_v1) {
4423 3084 $element = new Element_HTML("\n\n<!-- ReCaptcha 1 is discontinued, please go to Contact Forms settings page and set reCaptcha v2 keys -->\n\n");
4424 3085 } else {
4425 - $element = new AccuaForm_Element_Captcha2 ($istance_data['label'], '', $field_properties+$captcha_properties);
3086 + $element = new AccuaForm_Element_Captcha2 ($istance_data['label'], '', $captcha_properties);
4426 3087 }
4427 3088 break;
4428 - case 'turnstile':
4429 - $element = new AccuaForm_Element_Turnstile($istance_data['label'], $istance_data['istance_id'], $field_properties+array("description" => ""));
4430 - break;
4431 3089 case 'password':
4432 3090 $element = new Element_Password($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value']));
4433 3091 break;
4434 3092 case 'password-and-confirm':
4435 3093 $id_2 = "___{$istance_data['istance_id']}___confirmpass";
4436 - $element = new Element_Password($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value']));
3094 + $element = new Element_Password(__("Password", 'contact-forms'), $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value']));
4437 3095 $element_conf = new Element_Password(__("Confirm password", 'contact-forms'), $id_2, $field_properties+array('value'=>$istance_data['default_value']));
4438 3096 $element_conf_validator = new AccuaForm_Validation_Password();
4439 3097 $element_conf_validator->configure(array('otherPasswordFieldName'=>$istance_data['istance_id']));
4440 3098 $element_conf->setValidation($element_conf_validator);
@@ -4441,57 +3099,26 @@
4441 3099 break;
4442 3100 case 'date':
4443 3101 $element = new AccuaForm_Element_Date($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value'], 'minDate'=>$istance_data['min_date'], 'maxDate'=>$istance_data['max_date']));
4444 3102 break;
4445 - case 'telephone':
4446 - $phone_country = isset($istance_data['country_code']) ? $istance_data['country_code'] : 'IT';
4447 - $phone_props = $field_properties+array('value'=>$istance_data['default_value'], 'country_code'=>$phone_country);
4448 - if ($resolved_format_msg !== '') {
4449 - $phone_props['custom_format_message'] = $resolved_format_msg;
4450 - }
4451 - $element = new AccuaForm_Element_Telephone($istance_data['label'], $istance_data['istance_id'], $phone_props);
4452 - break;
4453 3103 //case 'textfield':
4454 3104 default:
4455 - /**
4456 - * Filter to create a custom Element for an external field type.
4457 - *
4458 - * @param Element|null $element Null by default; return an Element to override.
4459 - * @param string $field_type The field type identifier.
4460 - * @param array $field_data The field definition from avail_fields.
4461 - * @param array $istance_data The field instance data (label, required, etc.).
4462 - * @param array $field_properties Common properties (description, shortDesc, etc.).
4463 - */
4464 - $element = apply_filters( 'accua_forms_render_field_element', null, $field_data['type'], $field_data, $istance_data, $field_properties );
4465 - if ( ! $element ) {
4466 - $element = new Element_Textbox($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value']));
4467 - }
3105 + $element = new Element_Textbox($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value']));
4468 3106 break;
4469 3107 }
4470 3108 if ($element) {
4471 3109 if (!empty($istance_data['required'])) {
4472 3110 $element->setClass('accuaforms-field-required');
4473 - if ($field_data['type'] === 'captcha' && empty($captcha_use_v1)) {
3111 + if($field_data['type'] == 'captcha' && empty($captcha_use_v1)) {
4474 3112 //nothing
4475 - } elseif ($field_data['type'] === 'turnstile') {
4476 - //nothing - turnstile has its own validation set in the Element constructor
4477 - } elseif ($field_data['type'] === 'password-and-confirm') {
4478 - if ($resolved_required_msg !== '') {
4479 - $req_msg = str_replace(array('%s', '%element%'), $istance_data['label'], $resolved_required_msg);
4480 - } else {
4481 - /* translators: Password field required error */
4482 - $req_msg = __( 'Password is required', 'contact-forms' );
4483 - }
4484 - $element->setValidation(new Validation_Required($req_msg));
3113 + } else if($field_data['type'] == 'password-and-confirm') {
3114 + $element->setValidation(new Validation_Required(
3115 + str_replace('%element%', $istance_data['label'], __("Attention: Passwords are required fields.", 'contact-forms'))
3116 + ));
4485 3117 } else {
4486 - if ($resolved_required_msg !== '') {
4487 - $req_msg = str_replace(array('%s', '%element%'), $istance_data['label'], $resolved_required_msg);
4488 - } else {
4489 - /* translators: %element% is the field label, replaced with str_replace() */
4490 - // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment -- Translators comment is above
4491 - $req_msg = str_replace('%element%', $istance_data['label'], __( '%element% is required', 'contact-forms' ));
4492 - }
4493 - $element->setValidation(new Validation_Required($req_msg));
3118 + $element->setValidation(new Validation_Required(
3119 + str_replace('%element%', $istance_data['label'], __("Attention: '%element%' is a required field.", 'contact-forms'))
3120 + ));
4494 3121 }
4495 3122 }
4496 3123
4497 3124 if ($elementName = $element->getName()) {
@@ -4534,9 +3161,9 @@
4534 3161 if (!empty($params['txt'])) {
4535 3162 $replace_map['__submitted_txt'] = implode("\n",$replace_map['__submitted_txt_raw']);
4536 3163 }
4537 3164 if (!empty($params['html'])) {
4538 - $replace_map['__submitted_html'] = implode("</td></tr>\n<tr>\n<td style='white-space:nowrap;vertical-align:top;padding:4px 10px 4px 0;'>",$replace_map['__submitted_html_raw']);
3165 + $replace_map['__submitted_html'] = implode('</td></tr><tr><td>',$replace_map['__submitted_html_raw']);
4539 3166 }
4540 3167 if (!empty($params['json'])) {
4541 3168 $replace_map['__submitted_json'] = _accua_forms_json_encode($replace_map['__submitted_json_raw']);
4542 3169 }
@@ -4606,9 +3233,8 @@
4606 3233 ));
4607 3234
4608 3235 $anonymized_ip = accua_forms_anonymize_ip($form->stats['ip']);
4609 3236
4610 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Form submission insert requires direct query
4611 3237 $insert_ret = $wpdb->insert(
4612 3238 $wpdb->prefix . 'accua_forms_submissions',
4613 3239 array (
4614 3240 'afs_form_id' => (string) $fid,
@@ -4626,10 +3252,9 @@
4626 3252 if ($insert_ret) {
4627 3253 $submission_id = $form->stats['submission_id'] = $wpdb->insert_id;
4628 3254 } else {
4629 3255 $submission_id = $form->stats['submission_id'] = 0;
4630 - // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Legitimate error logging for failed DB insert
4631 - error_log("[Contact Forms] unable to save submitted form data");
3256 + error_log("[WordPress Contact Forms] unable to save submitted form data");
4632 3257 }
4633 3258
4634 3259 $review_submission_url = admin_url('admin.php').'?page=accua_forms_submissions_list&sid='.$submission_id;
4635 3260
@@ -4644,15 +3269,15 @@
4644 3269 '__referrer' => $form->stats['referrer'],
4645 3270 '__lang' => $form->stats['lang'],
4646 3271 '__locale' => $form->stats['locale'],
4647 3272 '__created' => $form->stats['created'],
4648 - '__created_day' => wp_date('l j F Y', $form->stats['created']),
4649 - '__created_day_month_year' => wp_date('j F Y', $form->stats['created']),
4650 - '__created_hour' => wp_date('G:i', $form->stats['created']),
3273 + '__created_day' => date('l j F Y', $form->stats['created']),
3274 + '__created_day_month_year' => date('j F Y', $form->stats['created']),
3275 + '__created_hour' => date('G:i', $form->stats['created']),
4651 3276 '__submitted' => $time,
4652 - '__submitted_day' => wp_date('l j F Y', $time),
4653 - '__submitted_day_month_year' => wp_date('j F Y', $time),
4654 - '__submitted_hour' => wp_date('G:i', $time),
3277 + '__submitted_day' => date('l j F Y', $time),
3278 + '__submitted_day_month_year' => date('j F Y', $time),
3279 + '__submitted_hour' => date('G:i', $time),
4655 3280 '__confirmation_emails_message' => $form_data['confirmation_emails_message'],
4656 3281 '__user_agent' => $form->stats['user_agent'],
4657 3282 '__platform' => $form->stats['platform'],
4658 3283 '__tentatives' => $form->stats['tentatives'],
@@ -4686,9 +3311,9 @@
4686 3311 'name' => __('Fieldset begin', 'contact-forms'),
4687 3312 'type' => 'fieldset-begin',
4688 3313 'description' => '',
4689 3314 );
4690 - } elseif ($istance_data['ref'] == '__fieldset-end') {
3315 + } else if ($istance_data['ref'] == '__fieldset-end') {
4691 3316 $field_data = array(
4692 3317 'id' => '__fieldset-end',
4693 3318 'name' => __('Fieldset end', 'contact-forms'),
4694 3319 'type' => 'fieldset-end',
@@ -4792,16 +3417,15 @@
4792 3417 }
4793 3418 break;
4794 3419 case 'post-select':
4795 3420 if ($value !== '') {
4796 - $post = get_post(absint($value));
4797 - $status_obj = $post ? get_post_status_object($post->post_status) : null;
4798 - if ($post && $status_obj && $status_obj->public) {
4799 - $title = $post->post_title;
4800 - $replace_map['__label_'.$istance_data['istance_id']] = $replace_map['__post_title_'.$istance_data['istance_id']] = $title;
3421 + $el = $form->getElementByName($istance_id);
3422 + $opts = $el->getOptions();
3423 + if (isset($opts[$value])) {
3424 + $replace_map['__label_'.$istance_data['istance_id']] = $replace_map['__post_title_'.$istance_data['istance_id']] = $opts[$value];
4801 3425 $replace_map['__post_id_'.$istance_data['istance_id']] = $value;
4802 3426 $replace_map['__post_url_'.$istance_data['istance_id']] = get_permalink($value);
4803 - $value = $value . ': ' . trim(preg_replace('/[\s\n\r]+/', ' ', $title));
3427 + $value = $value . ': ' . trim(preg_replace('/[\s\n\r]+/', ' ', $opts[$value]));
4804 3428 } else {
4805 3429 $replace_map['__label_'.$istance_data['istance_id']] = $replace_map['__post_title_'.$istance_data['istance_id']] = '';
4806 3430 $replace_map['__post_id_'.$istance_data['istance_id']] = '';
4807 3431 $replace_map['__post_url_'.$istance_data['istance_id']] = '';
@@ -4823,10 +3447,9 @@
4823 3447 if ($value !== null && $value !== '' && $file) {
4824 3448 if ($form->renameFile($istance_id, "{$submission_id}_{$field_data['id']}_{$file['name']}")) {
4825 3449 $urlfield = rawurlencode($istance_data['istance_id']);
4826 3450 $urlfile = rawurlencode($value);
4827 - $token = accua_forms_generate_download_token($submission_id);
4828 - $file_download_url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$submission_id}&field={$urlfield}&file={$urlfile}&nonce=" . wp_create_nonce('accua_forms_download_nonce')."&token={$token}&_wpnonce=" . wp_create_nonce('download_file_' . $submission_id . '_' . $urlfield);
3451 + $file_download_url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$submission_id}&field={$urlfield}&file={$urlfile}";
4829 3452 }
4830 3453 }
4831 3454 $replace_map[$istance_data['istance_id']] = $value;
4832 3455 $replace_map['__download_'.$istance_data['istance_id']] = $file_download_url;
@@ -4845,20 +3468,12 @@
4845 3468 $replace_map[$istance_data['istance_id']] = $value;
4846 3469 }
4847 3470
4848 3471 switch ($field_data['type']) {
4849 - case 'fieldset-begin':
4850 - $fieldset_label = !empty($istance_data['label']) ? esc_html($istance_data['label']) : esc_html($istance_data['istance_id']);
4851 - $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "\n--- {$istance_data['label']} ---";
4852 - $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = $value;
4853 - $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong style='font-size:14px;'>{$fieldset_label}</strong></td><td class='valori_submitted'>";
4854 - break;
4855 - case 'fieldset-end':
4856 - break;
4857 3472 case 'file':
4858 3473 $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value\t$file_download_url";
4859 3474 $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = "$value\t$file_download_url";
4860 - $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'><a href='".esc_url($file_download_url)."'>".esc_html($value)."</a>";
3475 + $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'><a href='".htmlspecialchars($file_download_url,ENT_QUOTES)."'>".htmlspecialchars($value)."</a>";
4861 3476 break;
4862 3477
4863 3478 case 'email':
4864 3479 case 'autoreply_email':
@@ -4863,9 +3478,9 @@
4863 3478 case 'email':
4864 3479 case 'autoreply_email':
4865 3480 $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value";
4866 3481 $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = $value;
4867 - $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'><a href='mailto:".esc_attr($value)."'>".esc_html($value)."</a>";
3482 + $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'><a href='mailto:".htmlspecialchars($value,ENT_QUOTES)."'>".htmlspecialchars($value)."</a>";
4868 3483 break;
4869 3484 case 'submit':
4870 3485 break;
4871 3486 case 'colorpicker':
@@ -4873,9 +3488,9 @@
4873 3488 $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = $value;
4874 3489 if ($value === '') {
4875 3490 $value_html = '';
4876 3491 } else {
4877 - $value_esc = esc_attr($value);
3492 + $value_esc = htmlspecialchars($value, ENT_QUOTES);
4878 3493 $value_html = "<span style='color: $value_esc'><font color='$value_esc'>&#9608;</font></span> $value_esc";
4879 3494 }
4880 3495 $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'>$value_html";
4881 3496 break;
@@ -4884,14 +3499,12 @@
4884 3499 break;
4885 3500 default:
4886 3501 $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value";
4887 3502 $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = $value;
4888 - $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'>".esc_html($value);
4889 - } if ($submission_id) {
4890 - // Ensure value is never NULL to prevent database errors
4891 - $safe_value = $value === null ? '' : $value;
4892 -
4893 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Form field values insert requires direct query
3503 + $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'>".htmlspecialchars($value);
3504 + }
3505 +
3506 + if ($submission_id) {
4894 3507 $wpdb->insert(
4895 3508 $wpdb->prefix . 'accua_forms_submissions_values',
4896 3509 array (
4897 3510 'afsv_sub_id' => $submission_id,
@@ -4896,9 +3509,9 @@
4896 3509 array (
4897 3510 'afsv_sub_id' => $submission_id,
4898 3511 'afsv_field_id' => $istance_data['istance_id'],
4899 3512 'afsv_type' => $type,
4900 - 'afsv_value' => $safe_value,
3513 + 'afsv_value' => $value,
4901 3514 ),
4902 3515 array('%d','%s','%s','%s')
4903 3516 );
4904 3517 }
@@ -4919,10 +3532,9 @@
4919 3532
4920 3533 //Newer filter, with an easier name
4921 3534 $replace_map = apply_filters('accua_forms_submission', $replace_map, $fid, $submittedData, $form, $_field_data, $_istance_data);
4922 3535
4923 - $submitted_html = "<table style='width:100%;border-collapse:collapse;'>\n<tr>\n<td style='white-space:nowrap;vertical-align:top;padding:4px 10px 4px 0;'>" . $replace_map['__submitted_html'] . "</td></tr></table>";
4924 - $submitted_html = str_replace("class='valori_submitted'", "class='valori_submitted' style='vertical-align:top;padding:4px 0;overflow-wrap:break-word;word-break:break-word;'", $submitted_html);
3536 + $submitted_html = '<table><tr><td>' . $replace_map['__submitted_html'] . '</td></tr></table>';
4925 3537 $confirmation_emails_message = $replace_map['__confirmation_emails_message'];
4926 3538 unset($replace_map['__submitted_html'], $replace_map['__confirmation_emails_message'], $replace_map['__submitted_txt_raw'], $replace_map['__submitted_html_raw'], $replace_map['__submitted_json_raw'], $replace_map['__autoreply_email_raw']);
4927 3539
4928 3540 $replace_map_html = array();
@@ -4927,9 +3539,9 @@
4927 3539
4928 3540 $replace_map_html = array();
4929 3541 foreach($replace_map as $key => $value) {
4930 3542 $replace_map_html["!$key"] = wp_kses($value, 'post');
4931 - $replace_map_html[$key] = esc_attr($value);
3543 + $replace_map_html[$key] = htmlspecialchars($value, ENT_QUOTES);
4932 3544 }
4933 3545
4934 3546 $replace_map['__submitted_html'] = $replace_map_html['__submitted_html'] = $replace_map_html['!__submitted_html'] = $submitted_html;
4935 3547 $replacer_html = new AccuaConditionalReplacer($replace_map_html);
@@ -4954,9 +3566,8 @@
4954 3566 }
4955 3567
4956 3568 $settings_html = array(
4957 3569 'success_message',
4958 - 'error_message',
4959 3570 'admin_emails_message',
4960 3571 );
4961 3572
4962 3573 foreach($settings_html as $i) {
@@ -4962,12 +3573,9 @@
4962 3573 foreach($settings_html as $i) {
4963 3574 $form_data_replaced[$i] = $replacer_html->doReplace($form_data[$i]);
4964 3575 }
4965 3576
4966 - // Track mail sending success for showing appropriate message
4967 - $mail_success = true;
4968 - $mail1 = true;
4969 - $mail2 = true;
3577 + AccuaForm::appendSubmittedMessages(wpautop($form_data_replaced['success_message']));
4970 3578
4971 3579 $header = array("Content-Type: text/html; charset=".get_option('blog_charset'));
4972 3580
4973 3581 $emails_from = trim($form_data_replaced['emails_from']);
@@ -4992,12 +3600,9 @@
4992 3600 foreach ($admin_tos as $admin_to) {
4993 3601 $mail1 = wp_mail(trim($admin_to), $form_data_replaced['admin_emails_subject'], $form_data_replaced['admin_emails_message'], $header);
4994 3602 }
4995 3603 */
4996 - $mail1 = wp_mail($form_data_replaced['admin_emails_to'], $form_data_replaced['admin_emails_subject'],'<html><head></head><body style="background:#f9f8f8;font-size: 12px;font-family: &quot;Lucida Sans&quot;,&quot;Lucida Grande&quot;, Verdana, Arial, Sans-Serif;">'.wpautop($form_data_replaced['admin_emails_message']).'</body></html>', $header);
4997 - if (!$mail1) {
4998 - $mail_success = false;
4999 - }
3604 + $mail1 = wp_mail($form_data_replaced['admin_emails_to'], $form_data_replaced['admin_emails_subject'],'<html><head></head><body style="background:#f9f8f8;font-size: 12px;font-family: "Lucida Sans","Lucida Grande", Verdana, Arial, Sans-Serif;"">'.wpautop($form_data_replaced['admin_emails_message']).'</body></html>', $header);
5000 3605 }
5001 3606
5002 3607 if ($replace_map['__autoreply'] && $replace_map['__autoreply_email']
5003 3608 && $form_data_replaced['confirmation_emails_subject']
@@ -5002,32 +3607,10 @@
5002 3607 if ($replace_map['__autoreply'] && $replace_map['__autoreply_email']
5003 3608 && $form_data_replaced['confirmation_emails_subject']
5004 3609 && $confirmation_emails_message) {
5005 3610 $mail2 = wp_mail($replace_map['__autoreply_email'], $form_data_replaced['confirmation_emails_subject'], '<html><head></head><body>'.wpautop($confirmation_emails_message).'</body></html>', $header);
5006 - if (!$mail2) {
5007 - $mail_success = false;
5008 - }
5009 3611 }
5010 3612
5011 - // Determine which message to show based on mail success and user settings
5012 - if ($mail_success) {
5013 - // Show success message unless "Don't show any messages" is selected
5014 - if (empty($form_data['success_message_no_message'])) {
5015 - $message_content = trim($form_data_replaced['success_message']);
5016 - if ($message_content !== '') {
5017 - AccuaForm::appendSubmittedMessages(wpautop($message_content));
5018 - }
5019 - }
5020 - } else {
5021 - // Mail failed - show error message unless "Don't show any messages" is selected
5022 - if (empty($form_data['error_message_no_message'])) {
5023 - $error_content = trim($form_data_replaced['error_message']);
5024 - if ($error_content !== '') {
5025 - AccuaForm::appendSubmittedMessages(wpautop($error_content));
5026 - }
5027 - }
5028 - }
5029 -
5030 3613 /*
5031 3614 echo "<!-- replace_map: "
5032 3615 , print_r($replace_map, true)
5033 3616 , "\nreplace_map: "
@@ -5055,16 +3638,11 @@
5055 3638 'file_format' => 'name',
5056 3639 );
5057 3640 $ret = array();
5058 3641 if ($options['extra']) {
5059 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Submission data lookup requires direct query
5060 - $query1 = $wpdb->prepare(
5061 - "SELECT *
3642 + $query1 = "SELECT *
5062 3643 FROM `{$wpdb->prefix}accua_forms_submissions`
5063 - WHERE afs_id = %d",
5064 - $subid
5065 - );
5066 - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- $query1 is prepared above, submission lookup requires direct query
3644 + WHERE afs_id = $subid";
5067 3645 $data = $wpdb->get_row($query1);
5068 3646 if (!empty($data)) {
5069 3647 $created = $data->afs_created;
5070 3648 $created[10] = 'T';
@@ -5097,13 +3675,13 @@
5097 3675 '__uri' => $data->afs_uri,
5098 3676 '__referrer' => $data->afs_referrer,
5099 3677 '__lang' => $data->afs_lang,
5100 3678 '__created' => $created,
5101 - '__created_day' => wp_date('l j F Y', $created),
5102 - '__created_hour' => wp_date('G:i', $created),
3679 + '__created_day' => date('l j F Y', $created),
3680 + '__created_hour' => date('G:i', $created),
5103 3681 '__submitted' => $submitted,
5104 - '__submitted_day' => wp_date('l j F Y', $submitted),
5105 - '__submitted_hour' => wp_date('G:i', $submitted),
3682 + '__submitted_day' => date('l j F Y', $submitted),
3683 + '__submitted_hour' => date('G:i', $submitted),
5106 3684 '__user_agent' => $stats['user_agent'],
5107 3685 '__platform' => $stats['platform'],
5108 3686 '__tentatives' => $stats['tentatives'],
5109 3687 '__submit_method' => $stats['submit_method'],
@@ -5110,17 +3688,12 @@
5110 3688 );
5111 3689 }
5112 3690 }
5113 3691
5114 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Submission values lookup requires direct query
5115 - $query2 = $wpdb->prepare(
5116 - "SELECT *
5117 - FROM `{$wpdb->prefix}accua_forms_submissions_values`
5118 - WHERE afsv_sub_id = %d",
5119 - $subid
5120 - );
3692 + $query2 = "SELECT *
3693 + FROM `{$wpdb->prefix}accua_forms_submissions_values`
3694 + WHERE afsv_sub_id = $subid";
5121 3695
5122 - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- $query2 is prepared above, submission values lookup requires direct query
5123 3696 $data2 = $wpdb->get_results($query2, OBJECT);
5124 3697
5125 3698 foreach ($data2 as $row) {
5126 3699 switch ($row->afsv_type) {
@@ -5127,15 +3700,12 @@
5127 3700 case 'file' :
5128 3701 if ($options['file_format'] == 'url' || $options['file_format'] == 'link') {
5129 3702 $fieldid = rawurlencode($row->afsv_field_id);
5130 3703 $filename = rawurlencode($row->afsv_value);
5131 - $url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$row->afsv_sub_id}&field={$fieldid}&file={$filename}&nonce=" . wp_create_nonce('accua_forms_download_nonce') . "&_wpnonce=" . wp_create_nonce('download_file_' . $row->afsv_sub_id . '_' . $fieldid);
5132 - if(isset($options['token'])){
5133 - $url .= '&token='.$options['token'];
5134 - }
3704 + $url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$row->afsv_sub_id}&field={$fieldid}&file={$filename}";
5135 3705 if ($options['file_format'] == 'link'){
5136 - $url = esc_url($url);
5137 - $filename = esc_html($row->afsv_value);
3706 + $url = htmlspecialchars($url,ENT_QUOTES);
3707 + $filename = htmlspecialchars($row->afsv_value,ENT_QUOTES);
5138 3708 $fielddata = "<a href='{$url}' target='_blank'>{$filename}</a>";
5139 3709 } else {
5140 3710 $fielddata = $url;
5141 3711 }
@@ -5160,20 +3730,11 @@
5160 3730 $fid = $atts['fid'];
5161 3731 $form_data = _accua_forms_get_form_data($fid, false);
5162 3732
5163 3733 if (! $form_data) {
5164 - // In preview mode, allow unsaved (new) forms to render using draft + defaults
5165 - if (! apply_filters('accua_forms_use_draft_for_preview', false)) {
5166 - return '';
5167 - }
5168 - $default_form_data = get_option('accua_forms_default_form_data', array());
5169 - $empty_form_data = _accua_forms_get_form_data(false);
5170 - $form_data = array('_overrided' => array()) + $default_form_data + $empty_form_data;
3734 + return '';
5171 3735 }
5172 3736
5173 - // Note: Preview field order override is handled in accua_forms_form_generate()
5174 - // which applies the filter there for live preview
5175 -
5176 3737 $fid = '__accua-form__'.$fid;
5177 3738
5178 3739 $out = '';
5179 3740
@@ -5178,24 +3739,12 @@
5178 3739 $out = '';
5179 3740
5180 3741 if (AccuaForm::getSubmittedID() == $fid) {
5181 3742 /* return "<pre>Form submitted.\n\nData: " . print_r(AccuaForm::getSubmittedData(), true) . '</pre>'; */
5182 - // Get per-form messages (supports multiple forms on same page)
5183 - $messages = AccuaForm::getSubmittedMessages($fid);
5184 - if ($messages && trim($messages) !== '') {
3743 + $messages = AccuaForm::getSubmittedMessages();
3744 + if ($messages) {
5185 3745 $out .= '<div id="_response_messages_'.$fid.'" class="accua-form-messages">'.$messages.'</div>';
5186 3746 }
5187 -
5188 - // Non-AJAX fallback: scroll to result anchor and set URL hash on page load
5189 - $anchor_suffix = preg_replace('/[^a-zA-Z0-9]+/', '_', str_replace('__accua-form__', '', $fid));
5190 - $hash_type = AccuaForm::isValid() ? 'formSubmitSuccess' : 'formSubmitInvalid';
5191 - $anchor_full = esc_js($hash_type . '-' . $anchor_suffix);
5192 - $out .= '<script>document.addEventListener("DOMContentLoaded",function(){'
5193 - . 'var t=document.getElementById("' . $anchor_full . '");'
5194 - . 'if(t){t.scrollIntoView({behavior:"smooth",block:"start"});'
5195 - . 'if(history.replaceState)history.replaceState(null,"","#' . $anchor_full . '")'
5196 - . '}});</script>';
5197 -
5198 3747 if (AccuaForm::isValid()) {
5199 3748 return $out;
5200 3749 }
5201 3750 $form = AccuaForm::getSubmittedForm();
@@ -5200,28 +3749,13 @@
5200 3749 }
5201 3750 $form = AccuaForm::getSubmittedForm();
5202 3751 } else {
5203 3752 $analytics_data = get_option('accua_forms_default_analytics_data',array());
5204 -
5205 - // Check for preview layout override (allows live preview of layout changes before save)
5206 - $layout = $form_data['layout'];
5207 - $preview_layout_override = apply_filters('accua_forms_preview_layout_override', '');
5208 - if ($preview_layout_override) {
5209 - $layout = $preview_layout_override;
5210 - }
5211 -
5212 - // If layout is empty (meaning "use default"), resolve to the global default layout
5213 - if (empty($layout)) {
5214 - $default_form_data = get_option('accua_forms_default_form_data', array());
5215 - $layout = !empty($default_form_data['layout']) ? $default_form_data['layout'] : 'sidebyside';
5216 - }
5217 -
5218 3753 $params = array(
5219 - 'layout' => $layout,
3754 + 'layout' => $form_data['layout'],
5220 3755 'title' => $form_data['title'],
5221 3756 'track_submit' => !empty($analytics_data['analytics_track_submit']),
5222 3757 'track_fields' => !empty($analytics_data['analytics_track_fields']),
5223 - 'gads_conversion_tracking_code' => $form_data['gads_conversion_tracking_code'],
5224 3758 );
5225 3759 $form = AccuaForm::create($fid, $params);
5226 3760 }
5227 3761
@@ -5227,10 +3761,9 @@
5227 3761
5228 3762 $out .= $form->render(true);
5229 3763
5230 3764 $doing_ajax = function_exists('wp_doing_ajax') ? wp_doing_ajax() : (defined( 'DOING_AJAX' ) && DOING_AJAX);
5231 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only check for Yoast SEO compatibility, strips HTML for preview
5232 - if ($doing_ajax && isset($_REQUEST['action']) && ($_REQUEST['action'] === 'wpseo_filter_shortcodes')) {
3765 + if ($doing_ajax && ($_REQUEST['action'] === 'wpseo_filter_shortcodes')) {
5233 3766 $strip_regexp = '/(<iframe[^>]*>(.*?)<\/iframe>|<script[^>]*>(.*?)<\/script>|<input([^>]*)type="hidden"[^>]*>)/is';
5234 3767 $out = preg_replace($strip_regexp, '', $out);
5235 3768 }
5236 3769
@@ -5239,15 +3772,12 @@
5239 3772 }
5240 3773
5241 3774 function accua_forms_include($fid, $atts=array(), $content = '', $code = '') {
5242 3775 $atts['fid'] = $fid;
5243 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Shortcode handler manages its own escaping
5244 3776 echo accua_forms_shortcode_handler($atts, $content, $code);
5245 3777 }
5246 3778
5247 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function, double underscore prefix indicates private
5248 3779 function __accua_forms_submissions_list_page(){
5249 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only routing, actual actions have nonce checks
5250 3780 if(isset($_GET['sid'])) {
5251 3781 accua_forms_single_submission();
5252 3782 } else {
5253 3783 accua_forms_submissions_list_page();
@@ -5252,23 +3782,9 @@
5252 3782 } else {
5253 3783 accua_forms_submissions_list_page();
5254 3784 }
5255 3785 }
5256 -function accua_forms_submissions_list_page_load(){
5257 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only routing for screen option registration
5258 - if(isset($_GET['sid'])) {
5259 - return;
5260 - }
5261 - add_screen_option('per_page', array(
5262 - 'default' => 100,
5263 - 'option' => 'accua_forms_submissions_per_page',
5264 - ));
5265 -}
5266 -add_filter('set_screen_option_accua_forms_submissions_per_page', function($status, $option, $value) {
5267 - return (int) $value;
5268 -}, 10, 3);
5269 3786 function accua_forms_submissions_list_page_head(){
5270 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only routing, actual actions have nonce checks
5271 3787 if(isset($_GET['sid'])) {
5272 3788 require_once('accua-forms-single-submission.php');
5273 3789 accua_forms_single_submission(true);
5274 3790 } else {
@@ -5277,127 +3793,21 @@
5277 3793 }
5278 3794
5279 3795 }
5280 3796
5281 -/* Generiamo token di sicurezza per poter accedere anche da anonimo - email */
5282 -function accua_forms_generate_download_token($subid) {
5283 - global $wpdb;
5284 - $token = wp_generate_password(32, false); // Token casuale di 32 caratteri
5285 -
5286 - // Controlla se esiste già un token per questo sub_id
5287 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Token lookup requires direct query
5288 - $existing_token = $wpdb->get_var($wpdb->prepare(
5289 - "SELECT afsv_value FROM `{$wpdb->prefix}accua_forms_submissions_values` WHERE afsv_sub_id = %d AND afsv_field_id = '_accua_download_token'",
5290 - $subid
5291 - ));
5292 - if ($existing_token) {
5293 - return $existing_token;
5294 - } else{
5295 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Token insert requires direct query
5296 - $wpdb->insert(
5297 - $wpdb->prefix . 'accua_forms_submissions_values',
5298 - [
5299 - 'afsv_sub_id' => $subid,
5300 - 'afsv_field_id' => '_accua_download_token',
5301 - 'afsv_type' => 'token',
5302 - 'afsv_value' => $token
5303 - ],
5304 - ['%d', '%s', '%s', '%s']
5305 - );
5306 - return $token;
5307 - }
5308 -}
5309 -
5310 -function accua_forms_check_download_token($subid, $get_token) {
5311 - global $wpdb;
5312 -
5313 - $subid = (int) $subid; // Cast to integer for security
5314 -
5315 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Token verification requires direct query
5316 - $saved_token = $wpdb->get_var($wpdb->prepare(
5317 - "SELECT afsv_value FROM `{$wpdb->prefix}accua_forms_submissions_values` WHERE afsv_sub_id = %d AND afsv_field_id = '_accua_download_token'",
5318 - $subid
5319 - ));
5320 -
5321 - // Debug logging for token verification (comment out in production)
5322 - // error_log("Token check: Submission ID: $subid, Provided token: $get_token, Saved token: $saved_token");
5323 -
5324 - return isset($get_token) && $get_token === $saved_token;
5325 -}
5326 -
5327 -/**
5328 - * Gestisce il download di un file inviato tramite un modulo.
5329 - *
5330 - * Questa funzione viene eseguita tramite una richiesta AJAX e permette agli utenti di scaricare
5331 - * un file precedentemente caricato con un modulo. Controlla i parametri della richiesta per verificare
5332 - * la presenza di un file associato a un determinato ID di invio e campo del modulo.
5333 - *
5334 - * - Se il parametro "html" è presente, genera una pagina HTML con un link di reindirizzamento automatico.
5335 - * - Recupera le informazioni del file dal database per verificarne l'esistenza.
5336 - * - Se il file esiste e può essere letto, restituisce il contenuto con gli appropriati header HTTP.
5337 - * - Se il file non viene trovato, restituisce un errore 404.
5338 - *
5339 - * Sicurezza:
5340 - * - Nonce
5341 - * - Utilizza `stripslashes_deep` per sanificare i dati in ingresso.
5342 - * - Protegge il database utilizzando `wpdb->prepare` per prevenire SQL Injection.
5343 - * - Determina il tipo MIME del file per un download sicuro.
5344 - * - Aggiunto token di verifica per utenti
5345 - */
5346 -
5347 3797 add_action('wp_ajax_accua_forms_download_submitted_file', 'accua_forms_download_submitted_file');
5348 3798 add_action('wp_ajax_nopriv_accua_forms_download_submitted_file', 'accua_forms_download_submitted_file');
5349 3799 function accua_forms_download_submitted_file(){
5350 3800 $get = stripslashes_deep($_GET);
5351 - $token_valid = false;
5352 - $nonce_valid = false;
5353 - $subid = '';
5354 -
5355 - if(isset($get['subid'])){
5356 - $subid = rawurlencode($get['subid']);
5357 - }
5358 -
5359 - // First verify WordPress nonce for CSRF protection (for logged-in users)
5360 - if (isset($get['_wpnonce']) && wp_verify_nonce($get['_wpnonce'], 'download_file_' . $subid . '_' . $get['field'])) {
5361 - $nonce_valid = true;
5362 - }
5363 -
5364 - // For backward compatibility with older URL format that use 'nonce' instead of '_wpnonce'
5365 - if (!$nonce_valid && isset($get['nonce']) && check_ajax_referer('accua_forms_download_nonce', 'nonce', false)) {
5366 - $nonce_valid = true;
5367 - }
5368 -
5369 - // Check for token-based authentication (for email links and unauthenticated users)
5370 - if (isset($get['token']) && $subid != '') {
5371 - if (accua_forms_check_download_token($subid, $get['token']) == 1) {
5372 - $token_valid = true;
5373 - }
5374 - }
5375 -
5376 - // If both authentication methods fail, deny access
5377 - if (!$nonce_valid && !$token_valid) {
5378 - wp_die(esc_html__('Security check failed.', 'contact-forms'), 403);
5379 - }
5380 - // Additional permission check for admin users
5381 - if(!$token_valid && !$nonce_valid && $subid != ''){
5382 - // If neither token nor nonce is valid, check for logged-in admin permissions
5383 - if (!is_user_logged_in() || !current_user_can('manage_options')) {
5384 - wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'contact-forms'));
5385 - }
5386 - }
5387 3801 if (isset($get['subid'],$get['field'],$get['file'])) {
5388 - if (!empty($get['html'])) { /* export xls*/
3802 + if (!empty($get['html'])) {
5389 3803 header("Content-type: text/html");
5390 3804 $subid = rawurlencode($get['subid']);
5391 3805 $fieldid = rawurlencode($get['field']);
5392 3806 $filename = rawurlencode($get['file']);
5393 - $url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$subid}&field={$fieldid}&file={$filename}&nonce=" . wp_create_nonce('accua_forms_download_nonce') . "&_wpnonce=" . wp_create_nonce('download_file_' . $subid . '_' . $fieldid);
5394 - if(isset($get['token'])){
5395 - $url .= '&token='.$get['token'];
5396 - }
5397 - $url = esc_url($url);
5398 - $filename = esc_html($get['file']);
5399 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $filename and $url are pre-escaped above
3807 + $url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$subid}&field={$fieldid}&file={$filename}";
3808 + $url = htmlspecialchars($url,ENT_QUOTES);
3809 + $filename = htmlspecialchars($get['file'],ENT_QUOTES);
5400 3810 die("<html><head><title>{$filename}</title><meta http-equiv='refresh' content='0;URL={$url}'></head><body><a href='{$url}'>{$filename}</a></body></html>");
5401 3811 }
5402 3812 global $wpdb;
5403 3813 $subid = (int) $get['subid'];
@@ -5402,19 +3812,15 @@
5402 3812 global $wpdb;
5403 3813 $subid = (int) $get['subid'];
5404 3814 $field = $get['field'];
5405 3815 $file = $get['file'];
5406 - $query = $wpdb->prepare(
5407 - "SELECT *
5408 - FROM `{$wpdb->prefix}accua_forms_submissions_values`
5409 - WHERE afsv_sub_id = %d
5410 - AND afsv_field_id = %s
5411 - AND afsv_value = %s",
5412 - $subid,
5413 - $field,
5414 - $file
5415 - );
5416 - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- $query is prepared above, file download verification requires direct query
3816 + $query = "SELECT *
3817 + FROM `{$wpdb->prefix}accua_forms_submissions_values`
3818 + WHERE afsv_sub_id = %d
3819 + AND afsv_field_id = %s
3820 + AND afsv_value = %s
3821 + ";
3822 + $query = $wpdb->prepare($query, $subid, $field, $file);
5417 3823 $subval = $wpdb->get_results($query, OBJECT);
5418 3824 if ($subval) {
5419 3825 $file_data = get_option('accua_forms_default_file_field_data',array()) + array('dest_path' => '');
5420 3826 $dest_path = _accua_forms_get_abs_dest_path($file_data['dest_path']);
@@ -5420,9 +3826,9 @@
5420 3826 $dest_path = _accua_forms_get_abs_dest_path($file_data['dest_path']);
5421 3827 $filename = "{$dest_path}/{$subid}_{$field}_{$file}";
5422 3828 if (is_file($filename) && is_readable($filename)){
5423 3829 if (function_exists('finfo_open')){
5424 - @ $finfo = finfo_open(FILEINFO_MIME_TYPE);
3830 + @ $finfo = finfo_open(FILEINFO_MIME);
5425 3831 if ($finfo) {
5426 3832 @ $filetype = finfo_file($finfo, $filename);
5427 3833 @ finfo_close($finfo);
5428 3834 }
@@ -5432,23 +3838,15 @@
5432 3838 }
5433 3839 if (empty($filetype)) {
5434 3840 $filetype = "application/octet-stream";
5435 3841 }
5436 - // Clean any output buffers to prevent stale content from being sent before the file
5437 - while (ob_get_level()) {
5438 - ob_end_clean();
5439 - }
5440 - // Remove all pre-set headers (admin-ajax.php sets Content-Type: text/html early)
5441 - header_remove();
5442 - nocache_headers();
5443 - header("Content-Type: $filetype");
5444 - header("Content-Length: ".filesize($filename));
3842 + header("Content-type: $filetype");
3843 + header("Content-length: ".filesize($filename));
5445 3844 if (empty($_GET['view'])) {
5446 - header("Content-Disposition: attachment; filename=\"$file\"");
3845 + header("Content-disposition: attachment; filename=\"$file\"");
5447 3846 }
5448 - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- WP_Filesystem not suitable for binary file streaming
5449 3847 readfile($filename);
5450 - exit;
3848 + die('');
5451 3849 }
5452 3850 }
5453 3851 }
5454 3852 header("HTTP/1.0 404 Not Found");
@@ -5468,87 +3866,17 @@
5468 3866 function accua_forms_preview() {
5469 3867 if (!current_user_can('manage_options')){
5470 3868 die ('');
5471 3869 }
5472 -
5473 - // Check nonce for CSRF protection
5474 - $nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : '';
5475 - if ( ! wp_verify_nonce( $nonce, 'accua_forms_preview' ) ) {
5476 - wp_die( esc_html__( 'Security check failed.', 'contact-forms' ), 403 );
5477 - }
5478 3870
5479 - // Enqueue form styles before printing them
5480 - accua_form_enqueue_scripts_and_styles();
5481 -
5482 - // Accept temporary layout override for live preview (before save)
5483 - // This allows real-time preview when user changes layout dropdown
5484 - $preview_layout = '';
5485 - if ( ! empty( $_REQUEST['preview_layout'] ) ) {
5486 - $layout_input = sanitize_text_field( wp_unslash( $_REQUEST['preview_layout'] ) );
5487 - $allowed_layouts = array( 'toplabel', 'sidebyside', 'inlinelabel' );
5488 - if ( in_array( $layout_input, $allowed_layouts, true ) ) {
5489 - $preview_layout = $layout_input;
5490 - } elseif ( 'default' === $layout_input ) {
5491 - // 'default' means use the global default layout
5492 - $default_form_data = get_option( 'accua_forms_default_form_data', array() );
5493 - $preview_layout = ! empty( $default_form_data['layout'] ) ? $default_form_data['layout'] : 'sidebyside';
5494 - }
5495 - }
5496 -
5497 - // Accept temporary field order for live preview (before save)
5498 - // This allows preview to show reordered fields without saving to database
5499 - $preview_order = null;
5500 - if ( ! empty( $_REQUEST['preview_order'] ) ) {
5501 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- JSON decoded and validated below
5502 - $order_json = wp_unslash( $_REQUEST['preview_order'] );
5503 - $preview_order = json_decode( $order_json, true );
5504 - if ( json_last_error() !== JSON_ERROR_NONE ) {
5505 - $preview_order = null;
5506 - }
5507 - }
5508 -
5509 - // Store the preview layout override in a filter so shortcode handler can use it
5510 - if ($preview_layout) {
5511 - add_filter('accua_forms_preview_layout_override', function() use ($preview_layout) {
5512 - return $preview_layout;
5513 - });
5514 - }
5515 -
5516 - // Store the preview order override in a filter so shortcode handler can use it
5517 - if ($preview_order) {
5518 - add_filter('accua_forms_preview_order_override', function() use ($preview_order) {
5519 - return $preview_order;
5520 - });
5521 - }
5522 -
5523 - // Signal that we're in admin preview mode - form generator should read from draft
5524 - add_filter('accua_forms_use_draft_for_preview', '__return_true');
5525 -
5526 3871 echo '<html><head>
5527 3872 <style>
5528 - *, *::before, *::after { box-sizing: border-box; }
5529 - body {
5530 - font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
5531 - margin: 0;
5532 - padding: 16px;
5533 - background: #fff;
5534 - font-size: 14px;
5535 - line-height: 1.5;
5536 - }
3873 + body {font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;}
5537 3874 </style>';
5538 3875 wp_print_styles();
5539 3876 wp_print_head_scripts();
5540 3877 echo '</head><body>';
5541 - $preview_fid = isset($_REQUEST['fid']) ? sanitize_text_field(wp_unslash($_REQUEST['fid'])) : '';
5542 -
5543 - // Check if the form has any fields — show placeholder if empty
5544 - $draft_data = _accua_forms_get_draft_data($preview_fid);
5545 - if (empty($draft_data['fields'])) {
5546 - echo '<p style="color:#50575e;text-align:center;margin-top:40px;">' . esc_html__('Add fields to the form to see the preview.', 'contact-forms') . '</p>';
5547 - } else {
5548 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Shortcode handler manages its own escaping
5549 - echo accua_forms_shortcode_handler(array('fid' => $preview_fid));
5550 - }
3878 + echo accua_forms_shortcode_handler(array('fid'=>$_REQUEST['fid']));
5551 3879 wp_print_footer_scripts();
5552 3880 echo '</body></html>';
5553 3881 die('');
5554 3882 }
@@ -5562,24 +3890,17 @@
5562 3890 header("HTTP/1.0 401 Access Denied");
5563 3891 //header("Status: 401 Access Denied");
5564 3892 die('You are not authorized to access this page.');
5565 3893 }
5566 -
5567 - // Check nonce for CSRF protection
5568 - if (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_wpnonce'])), 'accua_forms_export_excel')) {
5569 - wp_die(esc_html__('Security check failed.', 'contact-forms'), 403);
5570 - }
5571 3894
5572 3895 require_once('accua-forms-submissions-page.php');
5573 3896 $listTable = new Accua_Forms_Submissions_List_Table();
5574 3897 $listTable->export_xls = true;
5575 3898 $listTable->prepare_items(true);
5576 - // Sanitize column selection input
5577 - $show_col_input = isset($_GET['accua_show_field']) ? sanitize_text_field(wp_unslash($_GET['accua_show_field'])) : '';
5578 - $show_col = array_map('sanitize_key', explode(',', $show_col_input));
3899 + $show_col = explode( ',', $_GET['accua_show_field']);
5579 3900 $show_col = array_diff($show_col, array('singlesub'));
5580 - header('Content-disposition: attachment; filename=downloads-report.xls');
5581 - header('Content-type: application/vnd.ms-excel');
3901 + header("Content-disposition: attachment; filename=downloads-report.xls");
3902 + header("Content-type: application/vnd.ms-excel");
5582 3903 accua_forms_submission_page_save_excel_general($listTable,$show_col);
5583 3904 die('');
5584 3905 }
5585 3906
@@ -5594,9 +3915,9 @@
5594 3915 ?><html xmlns:o="urn:schemas-microsoft-com:office:office"
5595 3916 xmlns:x="urn:schemas-microsoft-com:office:excel"
5596 3917 xmlns="http://www.w3.org/TR/REC-html40">
5597 3918 <head>
5598 - <meta http-equiv=Content-Type content="<?php echo esc_attr( $content_type ); ?>" />
3919 + <meta http-equiv=Content-Type content="<?php echo $content_type; ?>" />
5599 3920 <meta name=ProgId content=Excel.Sheet />
5600 3921 <style>
5601 3922 <!--
5602 3923 td {vertical-align:top;}
@@ -5635,9 +3956,9 @@
5635 3956 <?php
5636 3957 $cols = $listTable->get_columns();
5637 3958 foreach($cols as $col_key=>$col_value) {
5638 3959 if(in_array($col_key, $show_col)) { ?>
5639 - <td x:autofilter="all"><?php echo esc_html( $col_value ); ?></td>
3960 + <td x:autofilter="all"><?php echo $col_value; ?></td>
5640 3961 <?php }
5641 3962 } ?>
5642 3963 </tr>
5643 3964
@@ -5644,24 +3965,22 @@
5644 3965 <?php
5645 3966 $lead_statuses = accua_forms_get_lead_statuses();
5646 3967
5647 3968 foreach($listTable->items as $id_submission=>$single_submission) {
5648 - // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged -- Required to prevent timeout during large exports
5649 3969 @ set_time_limit(10);
5650 3970 echo "<tr>";
5651 3971 foreach($cols as $col_key=>$col_value) {
5652 3972 if(in_array($col_key, $show_col)) {
5653 - echo '<td class="' . esc_attr($col_key) . '">';
3973 + echo "<td class='.$col_key.'>";
5654 3974 if ($col_key == 'lead_status') {
5655 3975 if (isset($lead_statuses[$single_submission['lead_status']])) {
5656 - echo esc_html($lead_statuses[$single_submission['lead_status']]);
3976 + echo htmlspecialchars($lead_statuses[$single_submission['lead_status']]);
5657 3977 }
5658 - } elseif(isset($single_submission[$col_key])) {
3978 + } else if(isset($single_submission[$col_key])) {
5659 3979 if ( method_exists( $listTable, 'column_' . $col_key ) ) {
5660 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- List table column methods handle their own escaping
5661 3980 echo call_user_func( array( &$listTable, 'column_' . $col_key ), $single_submission );
5662 - } else {
5663 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- List table column_default handles escaping
3981 + }
3982 + else {
5664 3983 echo $listTable->column_default( $single_submission, $col_key );
5665 3984 }
5666 3985 }
5667 3986 echo "</td>";
@@ -5681,36 +4000,34 @@
5681 4000 function accua_forms_print_tokens() {
5682 4001 $avail_fields = get_option('accua_forms_avail_fields', array());
5683 4002 $tokens = '';
5684 4003 foreach($avail_fields as $key=>$value) {
5685 - $field_name = $value['name'] ?? $value['label'] ?? $key;
5686 - $tokens .= $field_name . ": {" . $key . "}\n";
4004 + $tokens .= $value['name'] . ": {" . $key . "}\n";
5687 4005 switch ($value['type']) {
5688 4006 case 'file':
5689 - $tokens .= $field_name . " (download link): {__download_" . $key . "}\n";
4007 + $tokens .= $value['name'] . " (download link): {__download_" . $key . "}\n";
5690 4008 break;
5691 4009 case 'multiselect':
5692 4010 case 'multicheckbox':
5693 - $tokens .= $field_name . " (labels): {__label_" . $key . "}\n";
4011 + $tokens .= $value['name'] . " (labels): {__label_" . $key . "}\n";
5694 4012 break;
5695 4013 case 'select':
5696 4014 case 'radio':
5697 - $tokens .= $field_name . " (label): {__label_" . $key . "}\n";
4015 + $tokens .= $value['name'] . " (label): {__label_" . $key . "}\n";
5698 4016 break;
5699 4017 case 'post-multicheckbox':
5700 - $tokens .= $field_name . " (posts titles): {__label_" . $key . "}\n";
5701 - $tokens .= $field_name . " (posts ids): {__post_id_" . $key . "}\n";
5702 - $tokens .= $field_name . " (posts urls): {__post_url_" . $key . "}\n";
4018 + $tokens .= $value['name'] . " (posts titles): {__label_" . $key . "}\n";
4019 + $tokens .= $value['name'] . " (posts ids): {__post_id_" . $key . "}\n";
4020 + $tokens .= $value['name'] . " (posts urls): {__post_url_" . $key . "}\n";
5703 4021 break;
5704 4022 case 'post-select':
5705 - $tokens .= $field_name . " (post title): {__label_" . $key . "}\n";
5706 - $tokens .= $field_name . " (post id): {__post_id_" . $key . "}\n";
5707 - $tokens .= $field_name . " (post url): {__post_url_" . $key . "}\n";
4023 + $tokens .= $value['name'] . " (post title): {__label_" . $key . "}\n";
4024 + $tokens .= $value['name'] . " (post id): {__post_id_" . $key . "}\n";
4025 + $tokens .= $value['name'] . " (post url): {__post_url_" . $key . "}\n";
5708 4026 break;
5709 4027 }
5710 4028 }
5711 4029
5712 - // phpcs:disable PluginCheck.CodeAnalysis.Heredoc.NotAllowed, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped -- Heredoc for tokens help HTML
5713 4030 echo <<<EOT
5714 4031 <div class="accua_forms_token_list">
5715 4032 <h2>Tokens</h2>
5716 4033 <em>In HTML text, use {!token_name} to insert unfiltered token value</em>
@@ -5748,373 +4065,356 @@
5748 4065 {__confirmation_emails_message}
5749 4066 {__review_submission_url}</pre>
5750 4067 </div>
5751 4068 EOT;
5752 - // phpcs:enable PluginCheck.CodeAnalysis.Heredoc.NotAllowed, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped
5753 4069 do_action('accua_forms_print_tokens');
5754 4070 }
5755 4071
5756 -/**
5757 - * Get posts/pages for post-select fields using get_posts() for WPML compatibility.
5758 - *
5759 - * Uses WordPress get_posts() instead of direct SQL to ensure WPML and other
5760 - * language plugins can filter results to current language automatically.
5761 - *
5762 - * Performance considerations:
5763 - * - Results are cached using transients (5 minute TTL) to reduce database queries
5764 - * - meta_key/meta_value queries are necessary for filtering by custom fields
5765 - * - post__not_in is used only when exclude is explicitly requested by admin
5766 - * - Default limit of 500 posts prevents runaway queries
5767 - *
5768 - * @since 2.0.0-beta.29
5769 - * @param string|array $args Query arguments (backward compatible with old function).
5770 - * @return array Array of post objects.
5771 - */
5772 4072 function accua_get_pages($args = '') {
5773 - // phpcs:disable WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude, WordPress.DB.SlowDBQuery.slow_db_query_meta_key, WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- These are function parameter defaults, not actual query execution.
4073 + global $wpdb;
4074 +
5774 4075 $defaults = array(
5775 - 'child_of' => 0,
5776 - 'sort_order' => 'ASC',
5777 - 'sort_column' => 'post_title',
5778 - 'hierarchical' => 1,
5779 - 'exclude' => array(),
5780 - 'include' => array(),
5781 - 'meta_key' => '',
5782 - 'meta_value' => '',
5783 - 'meta_value_lt' => '',
5784 - 'meta_value_gt' => '',
5785 - 'meta_value_le' => '',
5786 - 'meta_value_ge' => '',
5787 - 'meta_value_like' => '',
5788 - 'meta_value_format' => 'string',
5789 - 'authors' => '',
5790 - 'parent' => -1,
5791 - 'exclude_tree' => '',
5792 - 'number' => 500, // Default limit for performance
5793 - 'offset' => 0,
5794 - 'post_type' => 'page',
5795 - 'post_status' => 'publish',
5796 - 'suppress_filters' => false, // IMPORTANT: Allow WPML to filter by language
5797 - 's' => '', // Search term (new parameter for AJAX search)
4076 + 'child_of' => 0,
4077 + 'sort_order' => 'ASC',
4078 + 'sort_column' => 'post_title',
4079 + 'hierarchical' => 1,
4080 + 'exclude' => array(),
4081 + 'include' => array(),
4082 + 'meta_key' => '',
4083 + 'meta_value' => '',
4084 + 'meta_value_lt' => '',
4085 + 'meta_value_gt' => '',
4086 + 'meta_value_le' => '',
4087 + 'meta_value_ge' => '',
4088 + 'meta_value_like' => '',
4089 + 'meta_value_format' => 'string',
4090 + 'authors' => '',
4091 + 'parent' => -1,
4092 + 'exclude_tree' => '',
4093 + 'number' => '',
4094 + 'offset' => 0,
4095 + 'post_type' => 'page',
4096 + 'post_status' => 'publish',
5798 4097 );
5799 - // phpcs:enable WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude, WordPress.DB.SlowDBQuery.slow_db_query_meta_key, WordPress.DB.SlowDBQuery.slow_db_query_meta_value
5800 4098
5801 - $r = wp_parse_args($args, $defaults);
4099 + $r = wp_parse_args( $args, $defaults );
4100 + $child_of = (int) $r['child_of'];
4101 + $sort_order = $r['sort_order'];
4102 + $sort_column = $r['sort_column'];
4103 + $hierarchical = $r['hierarchical'];
4104 + $exclude = $r['exclude'];
4105 + $include = $r['include'];
4106 + $meta_key = $r['meta_key'];
4107 + $meta_value = $r['meta_value'];
4108 + $meta_value_lt = $r['meta_value_lt'];
4109 + $meta_value_gt = $r['meta_value_gt'];
4110 + $meta_value_le = $r['meta_value_le'];
4111 + $meta_value_ge = $r['meta_value_ge'];
4112 + $meta_value_like = $r['meta_value_like'];
4113 + $meta_value_format = $r['meta_value_format'];
4114 + $authors = $r['authors'];
4115 + $parent = $r['parent'];
4116 + $exclude_tree = $r['exclude_tree'];
4117 + $number = (int) $r['number'];
4118 + $offset = (int) $r['offset'];
4119 + $post_type = $r['post_type'];
4120 + $post_status = $r['post_status'];
5802 4121
5803 - // Generate cache key based on arguments and current language
5804 - $cache_key_data = $r;
5805 - // Add current language to cache key for WPML/Polylang compatibility
5806 - if (function_exists('pll_current_language')) {
5807 - $cache_key_data['_lang'] = pll_current_language();
5808 - } elseif (defined('ICL_LANGUAGE_CODE')) {
5809 - $cache_key_data['_lang'] = ICL_LANGUAGE_CODE;
5810 - }
5811 - $cache_key = 'accua_pages_' . md5(wp_json_encode($cache_key_data));
4122 + /*
4123 + // Make sure the post type is hierarchical
4124 + $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) );
4125 + if ( !in_array( $post_type, $hierarchical_post_types ) )
4126 + return false;
4127 + */
5812 4128
5813 - // Check transient cache first (skip for search queries and random ordering)
5814 - $use_cache = empty($r['s']) && $r['sort_column'] !== 'rand';
5815 - if ($use_cache) {
5816 - $cached = get_transient($cache_key);
5817 - if ($cached !== false) {
5818 - return $cached;
5819 - }
5820 - }
4129 + // Make sure we have a valid post type
4130 + if ( !is_array( $post_type ) )
4131 + $post_type = explode( ',', $post_type );
4132 + if ( array_diff( $post_type, get_post_types() ) )
4133 + return false;
5821 4134
5822 - // Validate post type
5823 - $post_type = $r['post_type'];
5824 - if (!is_array($post_type)) {
5825 - $post_type = array_map('trim', explode(',', $post_type));
5826 - }
5827 - $valid_post_types = get_post_types();
5828 - $post_type = array_filter($post_type, function($pt) use ($valid_post_types) {
5829 - return in_array($pt, $valid_post_types, true);
5830 - });
5831 - if (empty($post_type)) {
5832 - return array();
5833 - }
4135 + // Make sure we have a valid post status
4136 + if ( !is_array( $post_status ) )
4137 + $post_status = explode( ',', $post_status );
4138 + if ( array_diff( $post_status, get_post_stati() ) )
4139 + return false;
5834 4140
5835 - // Validate post status
5836 - $post_status = $r['post_status'];
5837 - if (!is_array($post_status)) {
5838 - $post_status = array_map('trim', explode(',', $post_status));
4141 + /*
4142 + $cache = array();
4143 + $key = md5( serialize( compact(array_keys($defaults)) ) );
4144 + if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) {
4145 + if ( is_array($cache) && isset( $cache[ $key ] ) ) {
4146 + $pages = apply_filters('get_pages', $cache[ $key ], $r );
4147 + return $pages;
5839 4148 }
5840 - $valid_statuses = get_post_stati();
5841 - $post_status = array_filter($post_status, function($ps) use ($valid_statuses) {
5842 - return in_array($ps, $valid_statuses, true);
5843 - });
5844 - if (empty($post_status)) {
5845 - $post_status = array('publish');
5846 4149 }
5847 4150
5848 - // Map sort_column to orderby
5849 - $orderby_map = array(
5850 - 'post_title' => 'title',
5851 - 'title' => 'title',
5852 - 'post_date' => 'date',
5853 - 'date' => 'date',
5854 - 'post_modified' => 'modified',
5855 - 'modified' => 'modified',
5856 - 'menu_order' => 'menu_order',
5857 - 'post_name' => 'name',
5858 - 'name' => 'name',
5859 - 'post_parent' => 'parent',
5860 - 'parent' => 'parent',
5861 - 'ID' => 'ID',
5862 - 'rand' => 'rand',
5863 - 'comment_count' => 'comment_count',
5864 - 'post_author' => 'author',
5865 - 'author' => 'author',
5866 - );
5867 - $sort_column = $r['sort_column'];
5868 - $orderby = isset($orderby_map[$sort_column]) ? $orderby_map[$sort_column] : 'title';
4151 + if ( !is_array($cache) )
4152 + $cache = array();
4153 + */
5869 4154
5870 - // Build get_posts arguments
5871 - $query_args = array(
5872 - 'post_type' => $post_type,
5873 - 'post_status' => $post_status,
5874 - 'orderby' => $orderby,
5875 - 'order' => strtoupper($r['sort_order']) === 'DESC' ? 'DESC' : 'ASC',
5876 - 'posts_per_page' => !empty($r['number']) ? (int) $r['number'] : 500,
5877 - 'offset' => (int) $r['offset'],
5878 - 'suppress_filters' => (bool) $r['suppress_filters'],
5879 - );
5880 -
5881 - // Search term
5882 - if (!empty($r['s'])) {
5883 - $query_args['s'] = sanitize_text_field($r['s']);
4155 + $inclusions = '';
4156 + if ( !empty($include) ) {
4157 + $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4158 + $parent = -1;
4159 + $exclude = '';
4160 + $meta_key = '';
4161 + $meta_value = '';
4162 + $meta_value_lt = '';
4163 + $meta_value_gt = '';
4164 + $meta_value_le = '';
4165 + $meta_value_ge = '';
4166 + $meta_value_like = '';
4167 + $hierarchical = false;
4168 + $incpages = wp_parse_id_list( $include );
4169 + if ( ! empty( $incpages ) ) {
4170 + foreach ( $incpages as $incpage ) {
4171 + if (empty($inclusions))
4172 + $inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage);
4173 + else
4174 + $inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage);
4175 + }
4176 + }
5884 4177 }
4178 + if (!empty($inclusions))
4179 + $inclusions .= ')';
5885 4180
5886 - // Include specific posts (overrides other filters)
5887 - if (!empty($r['include'])) {
5888 - $include = wp_parse_id_list($r['include']);
5889 - if (!empty($include)) {
5890 - $query_args['post__in'] = $include;
5891 - $query_args['orderby'] = 'post__in'; // Preserve include order
5892 - }
5893 - } else {
5894 - // Exclude posts - only used when admin explicitly configures exclusions.
5895 - if (!empty($r['exclude'])) {
5896 - $exclude = wp_parse_id_list($r['exclude']);
5897 - if (!empty($exclude)) {
5898 - // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in -- Exclusion is an optional admin-configured feature, not default behavior.
5899 - $query_args['post__not_in'] = $exclude;
4181 + $exclusions = '';
4182 + if ( !empty($exclude) ) {
4183 + $expages = wp_parse_id_list( $exclude );
4184 + if ( ! empty( $expages ) ) {
4185 + foreach ( $expages as $expage ) {
4186 + if (empty($exclusions))
4187 + $exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage);
4188 + else
4189 + $exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage);
5900 4190 }
5901 4191 }
4192 + }
4193 + if (!empty($exclusions))
4194 + $exclusions .= ')';
5902 4195
5903 - // Parent filter
5904 - if ((int) $r['parent'] >= 0) {
5905 - $query_args['post_parent'] = (int) $r['parent'];
5906 - }
4196 + $author_query = '';
4197 + if (!empty($authors)) {
4198 + $post_authors = preg_split('/[\s,]+/',$authors);
5907 4199
5908 - // Child of (hierarchical)
5909 - if (!empty($r['child_of'])) {
5910 - $query_args['post_parent'] = (int) $r['child_of'];
5911 - }
4200 + if ( ! empty( $post_authors ) ) {
4201 + foreach ( $post_authors as $post_author ) {
4202 + //Do we have an author id or an author login?
4203 + if ( 0 == intval($post_author) ) {
4204 + $post_author = get_user_by('login', $post_author);
4205 + if ( empty($post_author) )
4206 + continue;
4207 + if ( empty($post_author->ID) )
4208 + continue;
4209 + $post_author = $post_author->ID;
4210 + }
5912 4211
5913 - // Authors filter
5914 - if (!empty($r['authors'])) {
5915 - $author_ids = array();
5916 - $post_authors = preg_split('/[\s,]+/', $r['authors']);
5917 - foreach ($post_authors as $post_author) {
5918 - $post_author = trim($post_author);
5919 - if (empty($post_author)) {
5920 - continue;
5921 - }
5922 - if (is_numeric($post_author)) {
5923 - $author_ids[] = (int) $post_author;
5924 - } else {
5925 - $user = get_user_by('login', $post_author);
5926 - if ($user && !empty($user->ID)) {
5927 - $author_ids[] = $user->ID;
5928 - }
5929 - }
4212 + if ( '' == $author_query )
4213 + $author_query = $wpdb->prepare(' post_author = %d ', $post_author);
4214 + else
4215 + $author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author);
5930 4216 }
5931 - if (!empty($author_ids)) {
5932 - $query_args['author__in'] = $author_ids;
5933 - }
4217 + if ( '' != $author_query )
4218 + $author_query = " AND ($author_query)";
5934 4219 }
4220 + }
5935 4221
5936 - // Build meta_query for advanced meta comparisons
5937 - $meta_query = array();
4222 + $allowed_keys = array('author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'name', 'post_name', 'modified',
4223 + 'post_modified', 'modified_gmt', 'post_modified_gmt', 'menu_order', 'parent', 'post_parent',
4224 + 'ID', 'rand', 'comment_count');
5938 4225
5939 - // Standard meta_key/meta_value - used for filtering posts by custom field.
5940 - // This is an optional admin-configured feature for advanced post filtering.
5941 - if (!empty($r['meta_key'])) {
5942 - // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- Required for custom field filtering feature.
5943 - $query_args['meta_key'] = stripslashes($r['meta_key']);
5944 - if (!empty($r['meta_value'])) {
5945 - // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- Required for custom field filtering feature.
5946 - $query_args['meta_value'] = stripslashes($r['meta_value']);
5947 - }
4226 + $join = '';
4227 + $where = "$exclusions $inclusions ";
4228 + if ( ! ( empty( $meta_key ) && empty( $meta_value )
4229 + && empty( $meta_value_lt ) && empty( $meta_value_gt )
4230 + && empty( $meta_value_le ) && empty( $meta_value_ge )
4231 + && empty( $meta_value_like ) ) ) {
4232 + $join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";
4233 + $allowed_keys[] = 'meta_key';
4234 + $allowed_keys[] = 'meta_value';
4235 +
4236 + // meta_key and meta_value might be slashed
4237 + $meta_key = stripslashes($meta_key);
4238 + $meta_value = stripslashes($meta_value);
4239 + $meta_value_lt = stripslashes($meta_value_lt);
4240 + $meta_value_gt = stripslashes($meta_value_gt);
4241 + $meta_value_le = stripslashes($meta_value_le);
4242 + $meta_value_ge = stripslashes($meta_value_ge);
4243 + $meta_value_like = stripslashes($meta_value_like);
4244 +
4245 + if ( ! empty( $meta_key ) ) {
4246 + $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key);
5948 4247 }
5949 4248
5950 - // Advanced meta comparisons (lt, gt, le, ge, like)
5951 - if (!empty($r['meta_key']) && (
5952 - !empty($r['meta_value_lt']) || !empty($r['meta_value_gt']) ||
5953 - !empty($r['meta_value_le']) || !empty($r['meta_value_ge']) ||
5954 - !empty($r['meta_value_like'])
5955 - )) {
5956 - $meta_key = stripslashes($r['meta_key']);
5957 - $meta_type = 'CHAR';
5958 - switch ($r['meta_value_format']) {
5959 - case 'int':
5960 - $meta_type = 'NUMERIC';
5961 - break;
5962 - case 'float':
5963 - $meta_type = 'DECIMAL';
5964 - break;
5965 - case 'timestamp':
5966 - $meta_type = 'DATETIME';
5967 - break;
5968 - }
4249 + $meta_value_field = "$wpdb->postmeta.meta_value";
4250 + $meta_value_timestamp = false;
4251 + switch($meta_value_format) {
4252 + case 'timestamp':
4253 + $meta_value_field = "TIMESTAMP( $meta_value_field )";
4254 + $meta_value_param = "FROM_UNIXTIME( %s )";
4255 + $meta_value_timestamp = true;
4256 + break;
4257 + case 'int':
4258 + $meta_value_param = "%d";
4259 + break;
4260 + case 'float':
4261 + $meta_value_param = "%f";
4262 + break;
4263 + //case 'string':
4264 + default:
4265 + $meta_value_param = "%s";
4266 + }
5969 4267
5970 - if (!empty($r['meta_value_lt'])) {
5971 - $value = stripslashes($r['meta_value_lt']);
5972 - if ($r['meta_value_format'] === 'timestamp') {
5973 - $value = gmdate('Y-m-d H:i:s', strtotime($value));
5974 - }
5975 - $meta_query[] = array(
5976 - 'key' => $meta_key,
5977 - 'value' => $value,
5978 - 'compare' => '<',
5979 - 'type' => $meta_type,
5980 - );
4268 + if ( ! empty( $meta_value ) ) {
4269 + if ($meta_value_timestamp) {
4270 + $meta_value = strtotime($meta_value);
5981 4271 }
5982 - if (!empty($r['meta_value_gt'])) {
5983 - $value = stripslashes($r['meta_value_gt']);
5984 - if ($r['meta_value_format'] === 'timestamp') {
5985 - $value = gmdate('Y-m-d H:i:s', strtotime($value));
5986 - }
5987 - $meta_query[] = array(
5988 - 'key' => $meta_key,
5989 - 'value' => $value,
5990 - 'compare' => '>',
5991 - 'type' => $meta_type,
5992 - );
4272 + $where .= $wpdb->prepare(" AND $meta_value_field = $meta_value_param", $meta_value);
4273 + }
4274 + if ( ! empty( $meta_value_lt ) ) {
4275 + if ($meta_value_timestamp) {
4276 + $meta_value_lt = strtotime($meta_value_lt);
5993 4277 }
5994 - if (!empty($r['meta_value_le'])) {
5995 - $value = stripslashes($r['meta_value_le']);
5996 - if ($r['meta_value_format'] === 'timestamp') {
5997 - $value = gmdate('Y-m-d H:i:s', strtotime($value));
5998 - }
5999 - $meta_query[] = array(
6000 - 'key' => $meta_key,
6001 - 'value' => $value,
6002 - 'compare' => '<=',
6003 - 'type' => $meta_type,
6004 - );
4278 + $where .= $wpdb->prepare(" AND $meta_value_field < $meta_value_param", $meta_value_lt);
4279 + }
4280 + if ( ! empty( $meta_value_gt ) ) {
4281 + if ($meta_value_timestamp) {
4282 + $meta_value_gt = strtotime($meta_value_gt);
6005 4283 }
6006 - if (!empty($r['meta_value_ge'])) {
6007 - $value = stripslashes($r['meta_value_ge']);
6008 - if ($r['meta_value_format'] === 'timestamp') {
6009 - $value = gmdate('Y-m-d H:i:s', strtotime($value));
6010 - }
6011 - $meta_query[] = array(
6012 - 'key' => $meta_key,
6013 - 'value' => $value,
6014 - 'compare' => '>=',
6015 - 'type' => $meta_type,
6016 - );
4284 + $where .= $wpdb->prepare(" AND $meta_value_field > $meta_value_param", $meta_value_gt);
4285 + }
4286 + if ( ! empty( $meta_value_le ) ) {
4287 + if ($meta_value_timestamp) {
4288 + $meta_value_le = strtotime($meta_value_le);
6017 4289 }
6018 - if (!empty($r['meta_value_like'])) {
6019 - $meta_query[] = array(
6020 - 'key' => $meta_key,
6021 - 'value' => stripslashes($r['meta_value_like']),
6022 - 'compare' => 'LIKE',
6023 - );
4290 + $where .= $wpdb->prepare(" AND $meta_value_field <= $meta_value_param", $meta_value_le);
4291 + }
4292 + if ( ! empty( $meta_value_ge ) ) {
4293 + if ($meta_value_timestamp) {
4294 + $meta_value_ge = strtotime($meta_value_ge);
6024 4295 }
6025 -
6026 - if (!empty($meta_query)) {
6027 - // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Required for advanced meta comparison operators (lt, gt, like, etc.).
6028 - $query_args['meta_query'] = $meta_query;
6029 - // Remove simple meta_value if we're using meta_query
6030 - unset($query_args['meta_value']);
4296 + $where .= $wpdb->prepare(" AND $meta_value_field >= $meta_value_param", $meta_value_ge);
4297 + }
4298 + if ( ! empty( $meta_value_like ) ) {
4299 + if ($meta_value_timestamp) {
4300 + $meta_value_like = strtotime($meta_value_like);
6031 4301 }
4302 + $where .= $wpdb->prepare(" AND $meta_value_field like $meta_value_param", $meta_value_like);
6032 4303 }
6033 4304 }
6034 4305
6035 - // Get posts using WordPress function (WPML automatically filters by current language)
6036 - $pages = get_posts($query_args);
4306 + if ( $parent >= 0 )
4307 + $where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
6037 4308
6038 - if (empty($pages)) {
6039 - // Cache empty results too (5 minutes)
6040 - if ($use_cache) {
6041 - set_transient($cache_key, array(), 5 * MINUTE_IN_SECONDS);
4309 +
4310 + if ( 1 == count ( $post_type ) ) {
4311 + $where_post_type = $wpdb->prepare( "post_type = %s", array_shift( $post_type ) );
4312 + } else {
4313 + $post_type = implode( "', '", $post_type );
4314 + $where_post_type = "post_type IN ('$post_type')";
4315 + }
4316 +
4317 + if ( 1 == count( $post_status ) ) {
4318 + $where_post_type .= $wpdb->prepare( " AND post_status = %s", array_shift( $post_status ) );
4319 + } else {
4320 + $post_status = implode( "', '", $post_status );
4321 + $where_post_type .= " AND post_status IN ('$post_status')";
4322 + }
4323 +
4324 + $orderby_array = array();
4325 + foreach ( explode( ',', $sort_column ) as $orderby ) {
4326 + $orderby = trim( $orderby );
4327 + if ( !in_array( $orderby, $allowed_keys ) )
4328 + continue;
4329 +
4330 + switch ( $orderby ) {
4331 + case 'menu_order':
4332 + break;
4333 + case 'ID':
4334 + $orderby = "$wpdb->posts.ID";
4335 + break;
4336 + case 'rand':
4337 + $orderby = 'RAND()';
4338 + break;
4339 + case 'comment_count':
4340 + $orderby = "$wpdb->posts.comment_count";
4341 + break;
4342 + case 'meta_key':
4343 + case 'meta_value':
4344 + $orderby = "$wpdb->postmeta.$orderby";
4345 + break;
4346 + default:
4347 + if ( 0 === strpos( $orderby, 'post_' ) )
4348 + $orderby = "$wpdb->posts." . $orderby;
4349 + else
4350 + $orderby = "$wpdb->posts.post_" . $orderby;
6042 4351 }
6043 - /**
6044 - * Filters the list of pages retrieved from accua_get_pages.
6045 - *
6046 - * @since 2.0.0-beta.29
6047 - *
6048 - * @param array $pages List of page objects.
6049 - * @param array $r Arguments passed to accua_get_pages.
6050 - */
6051 - return apply_filters('accua_forms_get_pages', array(), $r);
4352 +
4353 + $orderby_array[] = $orderby;
4354 +
6052 4355 }
4356 + $sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title";
6053 4357
6054 - // Handle hierarchical display with child_of
6055 - $child_of = (int) $r['child_of'];
6056 - $hierarchical = $r['hierarchical'];
6057 - if (($child_of || $hierarchical) && function_exists('get_page_children')) {
4358 + $sort_order = strtoupper( $sort_order );
4359 + if ( '' !== $sort_order && !in_array( $sort_order, array( 'ASC', 'DESC' ) ) )
4360 + $sort_order = 'ASC';
4361 +
4362 + $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where ";
4363 + $query .= $author_query;
4364 + $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
4365 +
4366 + if ( !empty($number) && !empty($offset) ) {
4367 + $query .= $wpdb->prepare(' LIMIT %d, %d', $offset, $number);
4368 + }
4369 +
4370 + //echo "<!-- accua_forms_query:\n$query\n-->";
4371 +
4372 + $pages = $wpdb->get_results($query);
4373 +
4374 + if ( empty($pages) ) {
4375 + $pages = apply_filters('get_pages', array(), $r);
4376 + return $pages;
4377 + }
4378 +
4379 + // Sanitize before caching so it'll only get done once
4380 + $num_pages = count($pages);
4381 + for ($i = 0; $i < $num_pages; $i++) {
4382 + $pages[$i] = sanitize_post($pages[$i], 'raw');
4383 + }
4384 +
4385 + /*
4386 + // Update cache.
4387 + update_post_cache( $pages );
4388 + */
4389 +
4390 + if ( $child_of || $hierarchical )
6058 4391 $pages = get_page_children($child_of, $pages);
6059 - }
6060 4392
6061 - // Exclude tree (remove a post and all its children)
6062 - if (!empty($r['exclude_tree'])) {
6063 - $exclude_tree = (int) $r['exclude_tree'];
6064 - $children = get_page_children($exclude_tree, $pages);
6065 - $excludes = array($exclude_tree);
6066 - foreach ($children as $child) {
4393 + if ( !empty($exclude_tree) ) {
4394 + $exclude = (int) $exclude_tree;
4395 + $children = get_page_children($exclude, $pages);
4396 + $excludes = array();
4397 + foreach ( $children as $child )
6067 4398 $excludes[] = $child->ID;
4399 + $excludes[] = $exclude;
4400 + $num_pages = count($pages);
4401 + for ( $i = 0; $i < $num_pages; $i++ ) {
4402 + if ( in_array($pages[$i]->ID, $excludes) )
4403 + unset($pages[$i]);
6068 4404 }
6069 - $pages = array_filter($pages, function($page) use ($excludes) {
6070 - return !in_array($page->ID, $excludes, true);
6071 - });
6072 - $pages = array_values($pages); // Re-index array
6073 4405 }
6074 4406
6075 - // Cache results for 5 minutes to improve performance
6076 - if ($use_cache) {
6077 - set_transient($cache_key, $pages, 5 * MINUTE_IN_SECONDS);
6078 - }
4407 + $pages = apply_filters('get_pages', $pages, $r);
6079 4408
6080 - /** This filter is documented above */
6081 - return apply_filters('accua_forms_get_pages', $pages, $r);
4409 + return $pages;
6082 4410 }
6083 4411
6084 -// phpcs:disable WordPress.DB.DirectDatabaseQuery
6085 4412 function accua_forms_trash_submission($id_sub){
6086 4413 global $wpdb;
6087 4414 return $wpdb->query($wpdb->prepare("UPDATE `{$wpdb->prefix}accua_forms_submissions` SET afs_status = -1 WHERE afs_id = %d", $id_sub)) !== FALSE;
6088 4415 }
6089 4416
6090 -function accua_forms_restore_submission($id_sub){
6091 - global $wpdb;
6092 - return $wpdb->query($wpdb->prepare("UPDATE `{$wpdb->prefix}accua_forms_submissions` SET afs_status = 0 WHERE afs_id = %d", $id_sub)) !== FALSE;
6093 -}
6094 -// phpcs:enable WordPress.DB.DirectDatabaseQuery
6095 -
6096 -/**
6097 - * Clear accua_get_pages cache when posts are modified.
6098 - *
6099 - * Called when posts are created, updated, deleted, or have status changed.
6100 - * This ensures that post-select dropdowns always show fresh data.
6101 - *
6102 - * @since 2.0.0-beta.29
6103 - * @param int $post_id Post ID that was modified.
6104 - */
6105 -function accua_forms_clear_pages_cache($post_id = 0) {
6106 - global $wpdb;
6107 - // Delete all transients that start with 'accua_pages_'
6108 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct query required to delete transients by prefix, and we're clearing cache not reading data.
6109 - $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_accua_pages_%' OR option_name LIKE '_transient_timeout_accua_pages_%'");
6110 -}
6111 -// Clear cache when posts are modified
6112 -add_action('save_post', 'accua_forms_clear_pages_cache');
6113 -add_action('delete_post', 'accua_forms_clear_pages_cache');
6114 -add_action('trash_post', 'accua_forms_clear_pages_cache');
6115 -add_action('untrash_post', 'accua_forms_clear_pages_cache');
6116 -
6117 4417 function accua_forms_get_lead_statuses() {
6118 4418 static $statuses = NULL;
6119 4419 if ($statuses === NULL) {
6120 4420 $statuses = array(
@@ -6139,18 +4439,16 @@
6139 4439 require_once('accua-forms-help.php');
6140 4440 }
6141 4441 $accuaHelp = AccuaFormsHelp::getInstance();
6142 4442 }
6143 - $subid = absint( $subid );
6144 - $original_lead_status = absint( $original_lead_status );
6145 - $nonce = esc_attr( wp_json_encode( wp_create_nonce( "set_lead_status_$subid" ) ) );
6146 - $ret = '<select onchange="accua_forms_set_lead_status(this, ' . $subid . ', ' . $nonce . ', ' . $original_lead_status . ')">';
4443 + $nonce = htmlspecialchars(_accua_forms_json_encode(wp_create_nonce( "set_lead_status_$subid" )),ENT_QUOTES);
4444 + $ret = "<select onchange=\"accua_forms_set_lead_status(this, $subid, $nonce, $original_lead_status)\">";
6147 4445 $statuses = accua_forms_get_lead_statuses();
6148 4446 foreach ($statuses as $k => $l) {
6149 - $selected = ( (int) $k === $original_lead_status ) ? ' selected="selected" ' : '';
6150 - $ret .= '<option value="' . esc_attr( $k ) . '"' . $selected . '>' . esc_html( $l ) . '</option>';
4447 + $selected = ($k == $original_lead_status) ? ' selected="selected" ' : '';
4448 + $ret .= "<option value=\"$k\"$selected>" . htmlspecialchars($l) . "</option>";
6151 4449 }
6152 - $ret .= '</select>' . $accuaHelp->add_pointer('contact_forms_lead_statuses') . "<span class='accua-forms-select-lead-status-progress'></span>";
4450 + $ret .= "</select>" . $accuaHelp->add_pointer('contact_forms_lead_statuses') . "<span class='accua-forms-select-lead-status-progress'></span>";
6153 4451 return $ret;
6154 4452 }
6155 4453
6156 4454 add_action( 'wp_ajax_accua-forms-set-lead-status' , 'accua_forms_set_lead_status');
@@ -6157,9 +4455,8 @@
6157 4455 function accua_forms_set_lead_status() {
6158 4456 if (!current_user_can('manage_options')){
6159 4457 wp_die(0, 403);
6160 4458 }
6161 - // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verification happens after subid is extracted via check_ajax_referer()
6162 4459 $post = $_POST + array(
6163 4460 'subid' => 0,
6164 4461 'lead_status' => 0,
6165 4462 );
@@ -6170,804 +4467,16 @@
6170 4467 $lead_status = (int) $post['lead_status'];
6171 4468 $statuses = accua_forms_get_lead_statuses();
6172 4469 if (isset($statuses[$lead_status])) {
6173 4470 global $wpdb;
6174 - // phpcs:disable WordPress.DB.DirectDatabaseQuery
6175 - $ret = $wpdb->update(
6176 - "{$wpdb->prefix}accua_forms_submissions",
4471 + $ret = $wpdb->update("{$wpdb->prefix}accua_forms_submissions",
6177 4472 array('afs_lead_status' => $lead_status),
6178 4473 array('afs_id' => $subid),
6179 - array('%d'),
6180 - array('%d')
4474 + '%d', '%d'
6181 4475 );
6182 - // phpcs:enable WordPress.DB.DirectDatabaseQuery
6183 4476 if ($ret !== FALSE) {
6184 - wp_die(1);
4477 + wp_die(1, 200);
6185 4478 }
6186 4479 }
6187 4480 }
6188 4481 wp_die(0, 500);
6189 -}
6190 -
6191 -/* =========================================================================
6192 - * GDPR DATA RETENTION & ANONYMIZATION
6193 - * ========================================================================= */
6194 -
6195 -add_action( 'wp_ajax_accua-forms-anonymize-submission', 'accua_forms_ajax_anonymize_submission' );
6196 -/**
6197 - * AJAX handler to anonymize a single submission.
6198 - */
6199 -function accua_forms_ajax_anonymize_submission() {
6200 - if ( ! current_user_can( 'manage_options' ) ) {
6201 - wp_die( 0, 403 );
6202 - }
6203 - // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified below after extracting subid
6204 - $subid = isset( $_POST['subid'] ) ? (int) $_POST['subid'] : 0;
6205 - if ( $subid ) {
6206 - check_ajax_referer( "anonymize_sub_{$subid}", '_nonce_anonymize' );
6207 - if ( accua_forms_erase_submission( $subid, 'anonymize' ) ) {
6208 - wp_die( 1 );
6209 - }
6210 - }
6211 - wp_die( 0, 500 );
6212 -}
6213 -
6214 -add_action( 'wp_ajax_accua_forms_bulk_anonymize_preview', 'accua_forms_ajax_bulk_anonymize_preview' );
6215 -/**
6216 - * AJAX handler to preview how many submissions per form would be anonymized.
6217 - */
6218 -function accua_forms_ajax_bulk_anonymize_preview() {
6219 - if ( ! current_user_can( 'manage_options' ) ) {
6220 - wp_send_json_error( array( 'message' => 'Permission denied.' ), 403 );
6221 - }
6222 - check_ajax_referer( 'accua_forms_danger_zone', 'nonce' );
6223 -
6224 - $value = isset( $_POST['value'] ) ? absint( $_POST['value'] ) : 0;
6225 - $unit = isset( $_POST['unit'] ) ? sanitize_key( wp_unslash( $_POST['unit'] ) ) : '';
6226 -
6227 - if ( $value < 1 || ! in_array( $unit, array( 'days', 'months', 'years' ), true ) ) {
6228 - wp_send_json_error( array( 'message' => __( 'Invalid period.', 'contact-forms' ) ) );
6229 - }
6230 -
6231 - $seconds = accua_forms_retention_to_seconds( $value, $unit );
6232 - $cutoff = gmdate( 'Y-m-d H:i:s', time() - $seconds );
6233 -
6234 - global $wpdb;
6235 - $table_subs = $wpdb->prefix . 'accua_forms_submissions';
6236 -
6237 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6238 - $rows = $wpdb->get_results( $wpdb->prepare(
6239 - "SELECT afs_form_id, COUNT(*) AS cnt FROM `{$table_subs}` WHERE afs_submitted < %s AND afs_anonymized = 0 GROUP BY afs_form_id ORDER BY cnt DESC",
6240 - $cutoff
6241 - ) );
6242 -
6243 - $forms_data = get_option( 'accua_forms_saved_forms', array() );
6244 - $total = 0;
6245 - $forms = array();
6246 -
6247 - foreach ( $rows as $row ) {
6248 - $fid = $row->afs_form_id;
6249 - $count = (int) $row->cnt;
6250 - $total += $count;
6251 - $title = isset( $forms_data[ $fid ]['title'] ) && $forms_data[ $fid ]['title'] !== ''
6252 - ? $forms_data[ $fid ]['title']
6253 - : sprintf( __( 'Form #%s', 'contact-forms' ), $fid );
6254 - $forms[] = array(
6255 - 'id' => $fid,
6256 - 'title' => $title,
6257 - 'count' => $count,
6258 - );
6259 - }
6260 -
6261 - wp_send_json_success( array(
6262 - 'total' => $total,
6263 - 'forms' => $forms,
6264 - ) );
6265 -}
6266 -
6267 -add_action( 'wp_ajax_accua_forms_bulk_anonymize', 'accua_forms_ajax_bulk_anonymize' );
6268 -/**
6269 - * AJAX handler to bulk-anonymize submissions older than a given period.
6270 - */
6271 -function accua_forms_ajax_bulk_anonymize() {
6272 - if ( ! current_user_can( 'manage_options' ) ) {
6273 - wp_send_json_error( array( 'message' => 'Permission denied.' ), 403 );
6274 - }
6275 - check_ajax_referer( 'accua_forms_danger_zone', 'nonce' );
6276 -
6277 - $value = isset( $_POST['value'] ) ? absint( $_POST['value'] ) : 0;
6278 - $unit = isset( $_POST['unit'] ) ? sanitize_key( wp_unslash( $_POST['unit'] ) ) : '';
6279 -
6280 - if ( $value < 1 || ! in_array( $unit, array( 'days', 'months', 'years' ), true ) ) {
6281 - wp_send_json_error( array( 'message' => __( 'Invalid period.', 'contact-forms' ) ) );
6282 - }
6283 -
6284 - $seconds = accua_forms_retention_to_seconds( $value, $unit );
6285 - $cutoff = gmdate( 'Y-m-d H:i:s', time() - $seconds );
6286 -
6287 - global $wpdb;
6288 - $table_subs = $wpdb->prefix . 'accua_forms_submissions';
6289 -
6290 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6291 - $ids = $wpdb->get_col( $wpdb->prepare(
6292 - "SELECT afs_id FROM `{$table_subs}` WHERE afs_submitted < %s AND afs_anonymized = 0",
6293 - $cutoff
6294 - ) );
6295 -
6296 - $count = 0;
6297 - foreach ( $ids as $id ) {
6298 - if ( accua_forms_erase_submission( (int) $id, 'anonymize' ) ) {
6299 - $count++;
6300 - }
6301 - }
6302 -
6303 - $unit_labels = array(
6304 - 'days' => __( 'days', 'contact-forms' ),
6305 - 'months' => __( 'months', 'contact-forms' ),
6306 - 'years' => __( 'years', 'contact-forms' ),
6307 - );
6308 -
6309 - wp_send_json_success( array(
6310 - 'message' => sprintf(
6311 - /* translators: 1: number of anonymized submissions, 2: total found, 3: retention period, 4: unit */
6312 - __( 'Done. %1$d of %2$d submissions older than %3$d %4$s have been anonymized.', 'contact-forms' ),
6313 - $count,
6314 - count( $ids ),
6315 - $value,
6316 - $unit_labels[ $unit ] ?? $unit
6317 - ),
6318 - ) );
6319 -}
6320 -
6321 -add_action( 'wp_ajax_accua_forms_delete_all_data', 'accua_forms_ajax_delete_all_data' );
6322 -/**
6323 - * AJAX handler to delete ALL Contact Forms plugin data.
6324 - */
6325 -function accua_forms_ajax_delete_all_data() {
6326 - if ( ! current_user_can( 'manage_options' ) ) {
6327 - wp_send_json_error( array( 'message' => 'Permission denied.' ), 403 );
6328 - }
6329 - check_ajax_referer( 'accua_forms_danger_zone', 'nonce' );
6330 -
6331 - $confirm_domain = isset( $_POST['confirm_domain'] ) ? sanitize_text_field( wp_unslash( $_POST['confirm_domain'] ) ) : '';
6332 - $expected = wp_parse_url( home_url(), PHP_URL_HOST );
6333 -
6334 - if ( $confirm_domain !== $expected ) {
6335 - wp_send_json_error( array( 'message' => __( 'Domain confirmation does not match.', 'contact-forms' ) ) );
6336 - }
6337 -
6338 - _accua_forms_delete_all_plugin_data();
6339 -
6340 - wp_send_json_success( array(
6341 - 'message' => __( 'All Contact Forms data has been deleted. The plugin is now reset. You may deactivate it or reload this page.', 'contact-forms' ),
6342 - ) );
6343 -}
6344 -
6345 -/**
6346 - * Delete all Contact Forms plugin data: uploaded files, DB tables, options, cron, and transients.
6347 - *
6348 - * Used by both the Danger Zone "Delete all data" and the deactivation cleanup handler.
6349 - */
6350 -function _accua_forms_delete_all_plugin_data() {
6351 - global $wpdb;
6352 -
6353 - // 1. Delete uploaded files
6354 - $dest_path = _accua_forms_get_abs_dest_path(
6355 - get_option( 'accua_forms_file_data', array() )['dest_path'] ?? ''
6356 - );
6357 - if ( is_dir( $dest_path ) ) {
6358 - accua_forms_recursive_rmdir( $dest_path );
6359 - }
6360 -
6361 - // 2. Drop custom database tables
6362 - $tables = array(
6363 - $wpdb->prefix . 'accua_forms_submissions_values',
6364 - $wpdb->prefix . 'accua_forms_submissions_notes',
6365 - $wpdb->prefix . 'accua_forms_submissions',
6366 - );
6367 - foreach ( $tables as $table ) {
6368 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange
6369 - $wpdb->query( "DROP TABLE IF EXISTS `{$table}`" );
6370 - }
6371 -
6372 - // 3. Delete all plugin options
6373 - $options = array(
6374 - 'accua_forms_saved_forms',
6375 - 'accua_forms_trash_forms',
6376 - 'accua_forms_default_form_data',
6377 - 'accua_forms_avail_fields',
6378 - 'accua_forms_avail_fields_order',
6379 - 'accua_forms_file_data',
6380 - 'accua_forms_anonymize_ip_data',
6381 - 'accua_forms_retention_data',
6382 - 'accua_forms_matomo_data',
6383 - 'accua_forms_ga_data',
6384 - 'accua_forms_style',
6385 - 'accua_forms_db_version',
6386 - 'accua_forms_layout',
6387 - 'accua_forms_lastid',
6388 - 'accua_form_api_keys',
6389 - );
6390 - foreach ( $options as $option ) {
6391 - delete_option( $option );
6392 - }
6393 -
6394 - // 4. Clear any pending cron events
6395 - wp_clear_scheduled_hook( 'accua_forms_retention_cleanup' );
6396 -
6397 - // 5. Delete draft transients
6398 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6399 - $wpdb->query(
6400 - "DELETE FROM `{$wpdb->options}` WHERE option_name LIKE '_transient_accua_forms_draft_%' OR option_name LIKE '_transient_timeout_accua_forms_draft_%'"
6401 - );
6402 -
6403 - // 6. Prevent accua_forms_check_db_version_and_update() from re-creating data
6404 - // during the deactivation redirect (plugin still loads once more).
6405 - set_transient( '_accua_forms_data_deleted', 1, 60 );
6406 -}
6407 -
6408 -add_action( 'wp_ajax_accua_forms_deactivation_cleanup', 'accua_forms_ajax_deactivation_cleanup' );
6409 -/**
6410 - * AJAX handler for the deactivation modal.
6411 - *
6412 - * Accepts a mode: 'delete' (remove all data), 'anonymize' (anonymize all submissions), or 'skip' (do nothing).
6413 - */
6414 -function accua_forms_ajax_deactivation_cleanup() {
6415 - if ( ! current_user_can( 'manage_options' ) ) {
6416 - wp_send_json_error( array( 'message' => 'Permission denied.' ), 403 );
6417 - }
6418 - check_ajax_referer( 'accua_forms_deactivation_cleanup', 'nonce' );
6419 -
6420 - $mode = isset( $_POST['mode'] ) ? sanitize_key( wp_unslash( $_POST['mode'] ) ) : '';
6421 -
6422 - if ( ! in_array( $mode, array( 'delete', 'anonymize' ), true ) ) {
6423 - wp_send_json_error( array( 'message' => __( 'Invalid mode.', 'contact-forms' ) ) );
6424 - }
6425 -
6426 - if ( $mode === 'delete' ) {
6427 - _accua_forms_delete_all_plugin_data();
6428 - wp_send_json_success();
6429 - }
6430 -
6431 - // Anonymize all non-anonymized submissions
6432 - global $wpdb;
6433 - $table_subs = $wpdb->prefix . 'accua_forms_submissions';
6434 -
6435 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6436 - $ids = $wpdb->get_col( "SELECT afs_id FROM `{$table_subs}` WHERE afs_anonymized = 0" );
6437 -
6438 - $count = 0;
6439 - foreach ( $ids as $id ) {
6440 - if ( accua_forms_erase_submission( (int) $id, 'anonymize' ) ) {
6441 - $count++;
6442 - }
6443 - }
6444 -
6445 - wp_send_json_success( array(
6446 - 'message' => sprintf(
6447 - /* translators: %d: number of submissions anonymized */
6448 - __( '%d submissions anonymized.', 'contact-forms' ),
6449 - $count
6450 - ),
6451 - ) );
6452 -}
6453 -
6454 -/**
6455 - * Recursively delete a directory and its contents.
6456 - *
6457 - * @param string $dir Directory path.
6458 - */
6459 -function accua_forms_recursive_rmdir( $dir ) {
6460 - if ( ! is_dir( $dir ) ) {
6461 - return;
6462 - }
6463 - $items = new RecursiveIteratorIterator(
6464 - new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ),
6465 - RecursiveIteratorIterator::CHILD_FIRST
6466 - );
6467 - global $wp_filesystem;
6468 - if ( ! function_exists( 'WP_Filesystem' ) ) {
6469 - require_once ABSPATH . 'wp-admin/includes/file.php';
6470 - }
6471 - WP_Filesystem();
6472 - foreach ( $items as $item ) {
6473 - if ( $item->isDir() ) {
6474 - $wp_filesystem->rmdir( $item->getRealPath() );
6475 - } else {
6476 - wp_delete_file( $item->getRealPath() );
6477 - }
6478 - }
6479 - $wp_filesystem->rmdir( $dir );
6480 -}
6481 -
6482 -/**
6483 - * Map a Contact Forms field type to a wp_privacy_anonymize_data() type.
6484 - *
6485 - * @param string $afsv_type Field type stored in afsv_type column.
6486 - * @return string One of 'email', 'url', 'text', 'longtext'.
6487 - */
6488 -function accua_forms_privacy_anonymize_type( $afsv_type ) {
6489 - $afsv_type = strtolower( $afsv_type );
6490 - switch ( $afsv_type ) {
6491 - case 'email':
6492 - case 'autoreply_email':
6493 - return 'email';
6494 - case 'url':
6495 - case 'website':
6496 - return 'url';
6497 - default:
6498 - return 'text';
6499 - }
6500 -}
6501 -
6502 -/**
6503 - * Erase or anonymize a single form submission.
6504 - *
6505 - * @param int $submission_id The afs_id of the submission.
6506 - * @param string $mode Either 'anonymize' or 'delete'.
6507 - * @return bool True if something was erased/anonymized.
6508 - */
6509 -function accua_forms_erase_submission( $submission_id, $mode = 'anonymize' ) {
6510 - global $wpdb;
6511 - $submission_id = absint( $submission_id );
6512 - if ( ! $submission_id ) {
6513 - return false;
6514 - }
6515 -
6516 - $table_subs = $wpdb->prefix . 'accua_forms_submissions';
6517 - $table_values = $wpdb->prefix . 'accua_forms_submissions_values';
6518 - $table_notes = $wpdb->prefix . 'accua_forms_submissions_notes';
6519 -
6520 - if ( $mode === 'delete' ) {
6521 - // Delete uploaded files first
6522 - accua_forms_delete_submission_files( $submission_id );
6523 -
6524 - // phpcs:disable WordPress.DB.DirectDatabaseQuery
6525 - $wpdb->delete( $table_values, array( 'afsv_sub_id' => $submission_id ), array( '%d' ) );
6526 - $wpdb->delete( $table_notes, array( 'afsn_sub_id' => $submission_id ), array( '%d' ) );
6527 - $wpdb->delete( $table_subs, array( 'afs_id' => $submission_id ), array( '%d' ) );
6528 - // phpcs:enable WordPress.DB.DirectDatabaseQuery
6529 - return true;
6530 - }
6531 -
6532 - // Anonymize mode
6533 -
6534 - // Delete uploaded files first
6535 - accua_forms_delete_submission_files( $submission_id );
6536 -
6537 - // Anonymize each field value based on its type
6538 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6539 - $fields = $wpdb->get_results( $wpdb->prepare(
6540 - "SELECT afsv_field_id, afsv_type FROM `{$table_values}` WHERE afsv_sub_id = %d",
6541 - $submission_id
6542 - ) );
6543 -
6544 - if ( $fields ) {
6545 - foreach ( $fields as $field ) {
6546 - $anon_type = accua_forms_privacy_anonymize_type( $field->afsv_type );
6547 - $anon_value = wp_privacy_anonymize_data( $anon_type );
6548 -
6549 - // Use our own string for text fields — WP's [deleted]/[eliminato] is ambiguous
6550 - if ( $anon_type === 'text' ) {
6551 - $anon_value = __( '[Anonymized]', 'contact-forms' );
6552 - }
6553 -
6554 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6555 - $wpdb->update(
6556 - $table_values,
6557 - array( 'afsv_value' => $anon_value ),
6558 - array( 'afsv_sub_id' => $submission_id, 'afsv_field_id' => $field->afsv_field_id ),
6559 - array( '%s' ),
6560 - array( '%d', '%s' )
6561 - );
6562 - }
6563 - }
6564 -
6565 - // Anonymize submission metadata (IP, stats)
6566 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6567 - $wpdb->update(
6568 - $table_subs,
6569 - array(
6570 - 'afs_ip' => '0.0.0.0',
6571 - 'afs_stats' => '',
6572 - 'afs_anonymized' => 1,
6573 - ),
6574 - array( 'afs_id' => $submission_id ),
6575 - array( '%s', '%s', '%d' ),
6576 - array( '%d' )
6577 - );
6578 -
6579 - // Anonymize notes — use our own string for consistency with field values
6580 - $anon_text = __( '[Anonymized]', 'contact-forms' );
6581 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6582 - $wpdb->query( $wpdb->prepare(
6583 - "UPDATE `{$table_notes}` SET afsn_text = %s, afsn_user = %s WHERE afsn_sub_id = %d",
6584 - $anon_text,
6585 - $anon_text,
6586 - $submission_id
6587 - ) );
6588 -
6589 - return true;
6590 -}
6591 -
6592 -/**
6593 - * Delete uploaded files associated with a submission.
6594 - *
6595 - * @param int $submission_id The afs_id of the submission.
6596 - */
6597 -function accua_forms_delete_submission_files( $submission_id ) {
6598 - global $wpdb;
6599 - $table_values = $wpdb->prefix . 'accua_forms_submissions_values';
6600 -
6601 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6602 - $file_fields = $wpdb->get_results( $wpdb->prepare(
6603 - "SELECT afsv_value FROM `{$table_values}` WHERE afsv_sub_id = %d AND afsv_type = 'file' AND afsv_value != ''",
6604 - $submission_id
6605 - ) );
6606 -
6607 - if ( ! $file_fields ) {
6608 - return;
6609 - }
6610 -
6611 - $upload_base = _accua_forms_get_abs_dest_path(
6612 - isset( get_option( 'accua_forms_default_file_field_data', array() )['dest_path'] )
6613 - ? get_option( 'accua_forms_default_file_field_data', array() )['dest_path']
6614 - : ''
6615 - );
6616 -
6617 - foreach ( $file_fields as $file_field ) {
6618 - $filename = $file_field->afsv_value;
6619 - if ( empty( $filename ) ) {
6620 - continue;
6621 - }
6622 - // The value is the filename within the upload directory
6623 - $filepath = trailingslashit( $upload_base ) . $filename;
6624 - // Safety: only delete if within the upload directory
6625 - $real_upload = realpath( $upload_base );
6626 - $real_file = realpath( $filepath );
6627 - if ( $real_file && $real_upload && strpos( $real_file, $real_upload ) === 0 ) {
6628 - wp_delete_file( $real_file );
6629 - }
6630 - }
6631 -}
6632 -
6633 -/**
6634 - * Find submission IDs for a given email address.
6635 - *
6636 - * Looks up submissions by matching email-type fields (afsv_type IN ('email', 'autoreply_email')).
6637 - *
6638 - * @param string $email_address Email to search for.
6639 - * @param int $page Page number (1-based).
6640 - * @param int $per_page Results per page.
6641 - * @return array Array of submission row objects (afs_id, afs_form_id).
6642 - */
6643 -function accua_forms_find_submissions_by_email( $email_address, $page = 1, $per_page = 50 ) {
6644 - global $wpdb;
6645 - $table_subs = $wpdb->prefix . 'accua_forms_submissions';
6646 - $table_values = $wpdb->prefix . 'accua_forms_submissions_values';
6647 -
6648 - $offset = ( $page - 1 ) * $per_page;
6649 -
6650 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6651 - return $wpdb->get_results( $wpdb->prepare(
6652 - "SELECT DISTINCT s.afs_id, s.afs_form_id
6653 - FROM `{$table_subs}` s
6654 - INNER JOIN `{$table_values}` sv ON s.afs_id = sv.afsv_sub_id
6655 - WHERE sv.afsv_type IN ('email', 'autoreply_email')
6656 - AND sv.afsv_value = %s
6657 - AND s.afs_status >= 0
6658 - AND s.afs_anonymized = 0
6659 - ORDER BY s.afs_id ASC
6660 - LIMIT %d OFFSET %d",
6661 - $email_address,
6662 - $per_page,
6663 - $offset
6664 - ) );
6665 -}
6666 -
6667 -/* -------------------------------------------------------------------------
6668 - * WordPress Privacy API — Personal Data Exporter
6669 - * ------------------------------------------------------------------------- */
6670 -
6671 -add_filter( 'wp_privacy_personal_data_exporters', 'accua_forms_register_privacy_exporter' );
6672 -/**
6673 - * Register the Contact Forms personal data exporter.
6674 - *
6675 - * @param array $exporters Registered exporters.
6676 - * @return array
6677 - */
6678 -function accua_forms_register_privacy_exporter( $exporters ) {
6679 - $exporters['contact-forms'] = array(
6680 - 'exporter_friendly_name' => __( 'Contact Forms Submissions', 'contact-forms' ),
6681 - 'callback' => 'accua_forms_privacy_exporter',
6682 - );
6683 - return $exporters;
6684 -}
6685 -
6686 -/**
6687 - * Export personal data for a given email address.
6688 - *
6689 - * @param string $email_address The email to export data for.
6690 - * @param int $page Page number.
6691 - * @return array Export data array with 'data' and 'done' keys.
6692 - */
6693 -function accua_forms_privacy_exporter( $email_address, $page = 1 ) {
6694 - global $wpdb;
6695 - $per_page = 50;
6696 - $export_items = array();
6697 - $table_subs = $wpdb->prefix . 'accua_forms_submissions';
6698 - $table_values = $wpdb->prefix . 'accua_forms_submissions_values';
6699 -
6700 - $submissions = accua_forms_find_submissions_by_email( $email_address, $page, $per_page );
6701 -
6702 - foreach ( $submissions as $sub ) {
6703 - $data = array();
6704 -
6705 - // Get submission metadata
6706 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6707 - $meta = $wpdb->get_row( $wpdb->prepare(
6708 - "SELECT afs_ip, afs_uri, afs_referrer, afs_submitted, afs_stats FROM `{$table_subs}` WHERE afs_id = %d",
6709 - $sub->afs_id
6710 - ) );
6711 -
6712 - if ( $meta ) {
6713 - if ( $meta->afs_ip !== '' ) {
6714 - $data[] = array(
6715 - 'name' => __( 'IP Address', 'contact-forms' ),
6716 - 'value' => $meta->afs_ip,
6717 - );
6718 - }
6719 - $data[] = array(
6720 - 'name' => __( 'Submitted', 'contact-forms' ),
6721 - 'value' => $meta->afs_submitted,
6722 - );
6723 - if ( $meta->afs_uri !== '' ) {
6724 - $data[] = array(
6725 - 'name' => __( 'Page URL', 'contact-forms' ),
6726 - 'value' => $meta->afs_uri,
6727 - );
6728 - }
6729 - if ( $meta->afs_referrer !== '' ) {
6730 - $data[] = array(
6731 - 'name' => __( 'Referrer', 'contact-forms' ),
6732 - 'value' => $meta->afs_referrer,
6733 - );
6734 - }
6735 - }
6736 -
6737 - // Get all field values
6738 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6739 - $fields = $wpdb->get_results( $wpdb->prepare(
6740 - "SELECT afsv_field_id, afsv_value FROM `{$table_values}` WHERE afsv_sub_id = %d",
6741 - $sub->afs_id
6742 - ) );
6743 -
6744 - foreach ( $fields as $field ) {
6745 - $data[] = array(
6746 - 'name' => $field->afsv_field_id,
6747 - 'value' => $field->afsv_value,
6748 - );
6749 - }
6750 -
6751 - $export_items[] = array(
6752 - 'group_id' => 'contact-form-submissions',
6753 - 'group_label' => __( 'Contact Form Submissions', 'contact-forms' ),
6754 - 'group_description' => __( 'Data submitted through contact forms on this site.', 'contact-forms' ),
6755 - 'item_id' => "contact-form-submission-{$sub->afs_id}",
6756 - 'data' => $data,
6757 - );
6758 - }
6759 -
6760 - return array(
6761 - 'data' => $export_items,
6762 - 'done' => count( $submissions ) < $per_page,
6763 - );
6764 -}
6765 -
6766 -/* -------------------------------------------------------------------------
6767 - * WordPress Privacy API — Personal Data Eraser
6768 - * ------------------------------------------------------------------------- */
6769 -
6770 -add_filter( 'wp_privacy_personal_data_erasers', 'accua_forms_register_privacy_eraser' );
6771 -/**
6772 - * Register the Contact Forms personal data eraser.
6773 - *
6774 - * @param array $erasers Registered erasers.
6775 - * @return array
6776 - */
6777 -function accua_forms_register_privacy_eraser( $erasers ) {
6778 - $erasers['contact-forms'] = array(
6779 - 'eraser_friendly_name' => __( 'Contact Forms Submissions', 'contact-forms' ),
6780 - 'callback' => 'accua_forms_privacy_eraser',
6781 - );
6782 - return $erasers;
6783 -}
6784 -
6785 -/**
6786 - * Erase personal data for a given email address.
6787 - *
6788 - * @param string $email_address The email to erase data for.
6789 - * @param int $page Page number.
6790 - * @return array Eraser response array.
6791 - */
6792 -function accua_forms_privacy_eraser( $email_address, $page = 1 ) {
6793 - $per_page = 50;
6794 - $items_removed = false;
6795 - $items_retained = false;
6796 - $messages = array();
6797 -
6798 - $submissions = accua_forms_find_submissions_by_email( $email_address, $page, $per_page );
6799 -
6800 - foreach ( $submissions as $sub ) {
6801 - $config = accua_forms_get_retention_config( $sub->afs_form_id );
6802 - $mode = $config['mode'];
6803 -
6804 - if ( accua_forms_erase_submission( $sub->afs_id, $mode ) ) {
6805 - $items_removed = true;
6806 - }
6807 - }
6808 -
6809 - return array(
6810 - 'items_removed' => $items_removed,
6811 - 'items_retained' => $items_retained,
6812 - 'messages' => $messages,
6813 - 'done' => count( $submissions ) < $per_page,
6814 - );
6815 -}
6816 -
6817 -/* -------------------------------------------------------------------------
6818 - * WordPress Privacy API — Privacy Policy Suggestion
6819 - * ------------------------------------------------------------------------- */
6820 -
6821 -add_action( 'admin_init', 'accua_forms_add_privacy_policy_content' );
6822 -/**
6823 - * Suggest privacy policy content for Contact Forms.
6824 - */
6825 -function accua_forms_add_privacy_policy_content() {
6826 - if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
6827 - return;
6828 - }
6829 -
6830 - $content = '<h2>' . __( 'Contact Forms', 'contact-forms' ) . '</h2>' .
6831 - '<p>' . __( 'When you submit a form on this site, we collect the data you provide in the form fields (such as your name, email address, phone number, and message), as well as your IP address and browser user-agent string to help spam detection.', 'contact-forms' ) . '</p>' .
6832 - '<p>' . __( 'If the form includes file upload fields, the uploaded files are stored on our server.', 'contact-forms' ) . '</p>' .
6833 - '<p>' . __( 'Form submissions are retained for the period configured by the site administrator. After the retention period expires, submissions are automatically anonymized or deleted depending on site settings.', 'contact-forms' ) . '</p>' .
6834 - '<p>' . __( 'If you request data erasure through the WordPress personal data erasure tool, all form submissions associated with your email address will be anonymized or deleted.', 'contact-forms' ) . '</p>';
6835 -
6836 - wp_add_privacy_policy_content( 'Contact Forms', wp_kses_post( $content ) );
6837 -}
6838 -
6839 -/* -------------------------------------------------------------------------
6840 - * Data Retention Settings — Resolution Helper
6841 - * ------------------------------------------------------------------------- */
6842 -
6843 -/**
6844 - * Get the retention configuration for a specific form.
6845 - *
6846 - * Checks per-form override first, then falls back to global default.
6847 - *
6848 - * @param string $form_id Form ID.
6849 - * @return array {
6850 - * @type int $seconds Retention period in seconds (0 = no expiry).
6851 - * @type string $mode 'anonymize' or 'delete'.
6852 - * }
6853 - */
6854 -function accua_forms_get_retention_config( $form_id = '' ) {
6855 - $default = array(
6856 - 'seconds' => 0,
6857 - 'mode' => 'anonymize',
6858 - );
6859 -
6860 - // Check per-form override
6861 - if ( $form_id !== '' ) {
6862 - $forms_data = get_option( 'accua_forms_saved_forms', array() );
6863 - if ( isset( $forms_data[ $form_id ] ) ) {
6864 - $form = $forms_data[ $form_id ];
6865 - if ( ! empty( $form['submission_retention_override'] ) ) {
6866 - $val = isset( $form['submission_retention_value'] ) ? (int) $form['submission_retention_value'] : 0;
6867 - $unit = isset( $form['submission_retention_unit'] ) ? $form['submission_retention_unit'] : 'months';
6868 - $mode = isset( $form['submission_retention_mode'] ) ? $form['submission_retention_mode'] : 'anonymize';
6869 - if ( $val > 0 ) {
6870 - return array(
6871 - 'seconds' => accua_forms_retention_to_seconds( $val, $unit ),
6872 - 'mode' => in_array( $mode, array( 'anonymize', 'delete' ), true ) ? $mode : 'anonymize',
6873 - );
6874 - }
6875 - return array( 'seconds' => 0, 'mode' => in_array( $mode, array( 'anonymize', 'delete' ), true ) ? $mode : 'anonymize' );
6876 - }
6877 - }
6878 - }
6879 -
6880 - // Fall back to global setting
6881 - $retention_data = get_option( 'accua_forms_retention_data', array() );
6882 - $val = isset( $retention_data['retention_value'] ) ? (int) $retention_data['retention_value'] : 0;
6883 - $unit = isset( $retention_data['retention_unit'] ) ? $retention_data['retention_unit'] : 'months';
6884 - $mode = isset( $retention_data['retention_mode'] ) ? $retention_data['retention_mode'] : 'anonymize';
6885 -
6886 - if ( $val > 0 ) {
6887 - return array(
6888 - 'seconds' => accua_forms_retention_to_seconds( $val, $unit ),
6889 - 'mode' => in_array( $mode, array( 'anonymize', 'delete' ), true ) ? $mode : 'anonymize',
6890 - );
6891 - }
6892 -
6893 - return $default;
6894 -}
6895 -
6896 -/**
6897 - * Convert a retention value + unit to seconds.
6898 - *
6899 - * @param int $value Retention value.
6900 - * @param string $unit 'days', 'months', or 'years'.
6901 - * @return int Seconds.
6902 - */
6903 -function accua_forms_retention_to_seconds( $value, $unit ) {
6904 - $value = max( 0, (int) $value );
6905 - switch ( $unit ) {
6906 - case 'days':
6907 - return $value * DAY_IN_SECONDS;
6908 - case 'years':
6909 - return $value * YEAR_IN_SECONDS;
6910 - case 'months':
6911 - default:
6912 - return $value * 30 * DAY_IN_SECONDS;
6913 - }
6914 -}
6915 -
6916 -/* -------------------------------------------------------------------------
6917 - * Data Retention — WP-Cron Cleanup Handler
6918 - * ------------------------------------------------------------------------- */
6919 -
6920 -add_action( 'accua_forms_retention_cleanup', 'accua_forms_retention_cleanup_handler' );
6921 -/**
6922 - * Cron callback: anonymize or delete expired submissions.
6923 - */
6924 -function accua_forms_retention_cleanup_handler() {
6925 - global $wpdb;
6926 - $table_subs = $wpdb->prefix . 'accua_forms_submissions';
6927 -
6928 - $forms_data = get_option( 'accua_forms_saved_forms', array() );
6929 - if ( ! is_array( $forms_data ) ) {
6930 - return;
6931 - }
6932 -
6933 - // Collect all unique form IDs that have submissions (including deleted forms)
6934 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6935 - $form_ids = $wpdb->get_col( "SELECT DISTINCT afs_form_id FROM `{$table_subs}` WHERE afs_status >= 0" );
6936 -
6937 - foreach ( $form_ids as $form_id ) {
6938 - $config = accua_forms_get_retention_config( $form_id );
6939 - if ( $config['seconds'] <= 0 ) {
6940 - continue;
6941 - }
6942 -
6943 - $cutoff = gmdate( 'Y-m-d H:i:s', time() - $config['seconds'] );
6944 -
6945 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
6946 - $expired_ids = $wpdb->get_col( $wpdb->prepare(
6947 - "SELECT afs_id FROM `{$table_subs}`
6948 - WHERE afs_form_id = %s
6949 - AND afs_submitted < %s
6950 - AND afs_status >= 0
6951 - AND ( %s = 'delete' OR afs_anonymized = 0 )
6952 - ORDER BY afs_id ASC
6953 - LIMIT 100",
6954 - $form_id,
6955 - $cutoff,
6956 - $config['mode']
6957 - ) );
6958 -
6959 - foreach ( $expired_ids as $sub_id ) {
6960 - accua_forms_erase_submission( (int) $sub_id, $config['mode'] );
6961 - }
6962 - }
6963 -}
6964 -
6965 -/**
6966 - * Self-healing: ensure the retention cron is scheduled.
6967 - */
6968 -add_action( 'admin_init', 'accua_forms_ensure_retention_cron' );
6969 -function accua_forms_ensure_retention_cron() {
6970 - if ( ! wp_next_scheduled( 'accua_forms_retention_cleanup' ) ) {
6971 - wp_schedule_event( time(), 'daily', 'accua_forms_retention_cleanup' );
6972 - }
6973 4482 }