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 | contact-forms.php +141 -414 2.2.01.9.2 View file →
@@ -1,11 +1,11 @@
1 1 <?php
2 2 /*
3 -Plugin Name: Contact Forms by Cimatti
4 -Description: Create accessible contact forms with drag-and-drop. WCAG 2.2 compliant with screen reader support, keyboard navigation, and clear error messages.
5 -Version: 2.2.0
6 -Plugin URI: https://www.cimatti.it/en/wordpress-plugins/contact-forms/
7 -Author: Cimatti
3 +Plugin Name: WordPress Contact Forms by Cimatti
4 +Description: Quickly create and publish forms in your WordPress powered website.
5 +Version: 1.9.2
6 +Plugin URI: https://www.cimatti.it/wordpress/contact-forms/
7 +Author: Cimatti Consulting
8 8 Author URI: https://www.cimatti.it
9 9 Text Domain: contact-forms
10 10 Domain Path: /languages
11 11 Requires at least: 3.5
@@ -13,10 +13,10 @@
13 13 License URI: http://www.gnu.org/licenses/gpl-2.0.html
14 14 */
15 15
16 16 /*
17 -Contact Forms by Cimatti
18 -Copyright (c) 2011-2026 Andrea Cimatti
17 +WordPress Contact Forms by Cimatti
18 +Copyright (c) 2011-2024 Andrea Cimatti
19 19
20 20 This program is free software; you can redistribute it and/or
21 21 modify it under the terms of the GNU General Public License
22 22 as published by the Free Software Foundation; either version 2
@@ -35,47 +35,33 @@
35 35 The full copy of the GNU General Public License is available here: http://www.gnu.org/licenses/gpl.txt
36 36
37 37 */
38 38
39 -if ( ! defined( 'ABSPATH' ) ) exit;
40 -
41 -define('ACCUA_FORMS_DB_VERSION', '14');
42 -define('ACCUA_FORMS_CSS_VERSION', 175);
43 -define('ACCUA_FORMS_JS_VERSION', '108');
39 +define('ACCUA_FORMS_DB_VERSION', '12');
40 +define('ACCUA_FORMS_CSS_VERSION', '53');
41 +define('ACCUA_FORMS_JS_VERSION', '9');
44 42 define('ACCUA_FORMS_FILE', __FILE__);
45 -define('ACCUA_FORMS_DIR_URL', plugin_dir_url(ACCUA_FORMS_FILE));
46 -define('ACCUA_FORMS_DIR', dirname(ACCUA_FORMS_FILE));
43 +define('ACCUA_FORMS_DIR_URL', plugin_dir_url( ACCUA_FORMS_FILE ));
44 +define('ACCUA_FORMS_DIR', dirname( ACCUA_FORMS_FILE ));
47 45
48 46 require_once('accua-form-api.php');
49 47 require_once('accua-forms.php');
50 48 require_once('accua-shortcode-button.php');
51 -require_once('accua-forms-theme-helper.php');
52 -require_once('block-editor.php');
53 49
54 -/**
55 - * Load plugin textdomain for translations.
56 - *
57 - * Supports Italian and English only. Other language files have been removed
58 - * as they were incomplete or obsolete.
59 - */
60 -add_action('init', 'accua_forms_load_textdomain');
61 -function accua_forms_load_textdomain() {
62 - load_plugin_textdomain('contact-forms', false, dirname(plugin_basename(ACCUA_FORMS_FILE)) . '/languages');
63 -}
64 -
65 -function accua_forms_dashboard_page_head()
66 -{
50 +function accua_forms_dashboard_page_head(){
67 51 $screen = get_current_screen();
68 - $screen->add_help_tab(array(
69 - 'id' => 'accua_help_tab',
70 - 'title' => __('Contact Forms Dashboard', 'contact-forms'),
71 - 'content' => '<p>' . __('Marketing tools for WordPress', 'contact-forms') . '</p>',
72 - ));
52 + $screen->add_help_tab( array(
53 + 'id' => 'accua_help_tab',
54 + 'title' => __('Contact Forms Dashboard'),
55 + 'content' => '<p>' . __( 'Marketing tools for WordPress', 'contact-forms') . '</p>',
56 + ) );
73 57
74 - wp_enqueue_script('accua_chart_js', plugins_url('assets/vendor/chartjs/chart.umd.min.js', ACCUA_FORMS_FILE), array('jquery'), ACCUA_FORMS_JS_VERSION, true);
75 - wp_enqueue_style('accua-forms-admin', plugins_url('assets/css/admin.css', ACCUA_FORMS_FILE), array(), ACCUA_FORMS_CSS_VERSION);
58 + //wp_enqueue_script('accua', plugins_url('/flot/jquery.flot.js', ACCUA_FORMS_FILE ), array( 'jquery' ));
59 + wp_enqueue_script('accua_chart_js', plugins_url('/chartjs/Chart.min.js', ACCUA_FORMS_FILE ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION);
60 + //wp_enqueue_style('accua_flot', plugins_url('/flot/layout.css', ACCUA_FORMS_FILE ));
61 + wp_enqueue_style('accua', plugins_url('accua.css', ACCUA_FORMS_FILE ), array(), ACCUA_FORMS_CSS_VERSION);
76 62
77 - /* Tentativo x drag and drop
63 + /* Tentativo x drag and drop
78 64 $page_hook_id = fx_smb_setings_page_id();
79 65 /* Load the JavaScript needed for the settings screen. * /
80 66 add_action( 'admin_enqueue_scripts', 'fx_smb_enqueue_scripts' );
81 67 add_action( "admin_footer-{$page_hook_id}", 'fx_smb_footer_scripts' );
@@ -84,101 +70,64 @@
84 70 add_filter( 'screen_layout_columns', 'fx_smb_screen_layout_column', 10, 2 );
85 71 */
86 72 }
87 73
88 -/**
89 - * Add Contact Forms dashboard widget.
90 - *
91 - * Only visible to users with 'edit_posts' capability (administrators and editors).
92 - */
93 -add_action('wp_dashboard_setup', 'accua_contact_forms_dashboard_add_widgets');
94 -function accua_contact_forms_dashboard_add_widgets()
95 -{
96 - // Only add the dashboard widget for users with edit_posts capability (administrators and editors)
97 - if (current_user_can('edit_posts')) {
98 - wp_add_dashboard_widget('accua_contact_forms_dashboard_widget_news', __('Contact Forms', 'contact-forms'), 'accua_contact_forms_dashboard_widget_news_handler');
99 - }
74 +/* COSA CARINA PER AGGIUNGERE WIDGET NELLA DASHBOARD DI WP
75 +todo: posso scegliere la sua posizione di default?
76 +*/
77 +add_action( 'wp_dashboard_setup', 'accua_contact_forms_dashboard_add_widgets' );
78 +function accua_contact_forms_dashboard_add_widgets() {
79 + wp_add_dashboard_widget( 'accua_contact_forms_dashboard_widget_news', __( 'Contact Forms', 'contact-forms' ), 'accua_contact_forms_dashboard_widget_news_handler' );
100 80 }
101 81
102 -/**
103 - * Dashboard widget handler for Contact Forms stats.
104 - *
105 - * Shows form statistics including active forms, pages, submissions, and distinct emails.
106 - * Only accessible to users with 'edit_posts' capability.
107 - */
108 -function accua_contact_forms_dashboard_widget_news_handler()
109 -{
110 - // Double-check user capabilities for security
111 - if (!current_user_can('edit_posts')) {
112 - wp_die(esc_html__('You do not have sufficient permissions to access this content.', 'contact-forms'));
113 - }
114 -
115 - global $wpdb; ?>
116 - <table>
117 - <tr class="first">
118 - <?php $forms_data = get_option('accua_forms_saved_forms', array());
119 - $active_forms = count($forms_data); ?>
120 - <td class="first b"><?php echo esc_html($active_forms); ?></td>
121 - <td class="t"><?php esc_html_e('Active forms', 'contact-forms'); ?></td>
122 - </tr>
123 - <tr class="first">
124 - <?php
125 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Dashboard stats, no caching needed
126 - $pages = $wpdb->get_var("SELECT COUNT(DISTINCT afs_uri) FROM `{$wpdb->prefix}accua_forms_submissions`"); ?>
127 - <td class="first b"><?php echo esc_html($pages); ?></td>
128 - <td class="t"><?php esc_html_e('Pages', 'contact-forms'); ?></td>
129 - </tr>
130 - <tr class="first">
131 - <?php
132 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Dashboard stats, no caching needed
133 - $active_submissions = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}accua_forms_submissions` WHERE afs_status >= 0"); ?>
134 - <td class="first b"><?php echo esc_html($active_submissions); ?></td>
135 - <td class="t"><?php esc_html_e('Submissions', 'contact-forms'); ?></td>
136 - </tr>
137 - <tr class="first">
138 - <?php
139 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Dashboard stats, no caching needed
140 - $emails = $wpdb->get_var("SELECT COUNT(DISTINCT afsv_value) FROM `{$wpdb->prefix}accua_forms_submissions_values` WHERE afsv_type LIKE 'autoreply_email'"); ?>
141 - <td class="first b"><?php echo esc_html($emails); ?></td>
142 - <td class="t"><?php esc_html_e('Distinct Emails', 'contact-forms'); ?></td>
143 - </tr>
144 - </table>
145 - <br />
146 - <span id="accua-forms-version"><a href="https://www.cimatti.it/en/wordpress-plugins/contact-forms/">
147 - <?php
148 - $plugin_data = get_plugin_data(ACCUA_FORMS_FILE);
149 - esc_html_e('Version', 'contact-forms');
150 - echo " " . esc_html($plugin_data['Version']); ?></a> | <a href="admin.php?page=accua_forms" title="Contact Forms Dashboard"><?php esc_html_e('Dashboard', 'contact-forms'); ?></a>
151 - </span>
82 +function accua_contact_forms_dashboard_widget_news_handler() {
83 + global $wpdb; ?>
84 + <table>
85 + <tr class="first">
86 + <?php $forms_data = get_option('accua_forms_saved_forms', array());
87 + $active_forms = count($forms_data); ?>
88 + <td class="first b"><?php echo $active_forms; ?></td><td class="t"><?php _e('Active forms', 'contact-forms'); ?></td>
89 + </tr>
90 + <tr class="first">
91 + <?php $pages = $wpdb->get_var("SELECT COUNT(DISTINCT afs_uri) FROM `{$wpdb->prefix}accua_forms_submissions`"); ?>
92 + <td class="first b"><?php echo $pages; ?></td><td class="t"><?php _e('Pages', 'contact-forms'); ?></td>
93 + </tr>
94 + <tr class="first">
95 + <?php $active_submissions = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}accua_forms_submissions` WHERE afs_status >= 0"); ?>
96 + <td class="first b"><?php echo $active_submissions; ?></td><td class="t"><?php _e('Submissions', 'contact-forms'); ?></td>
97 + </tr>
98 + <tr class="first">
99 + <?php $emails = $wpdb->get_var("SELECT COUNT(DISTINCT afsv_value) FROM `{$wpdb->prefix}accua_forms_submissions_values` WHERE afsv_type LIKE 'autoreply_email'"); ?>
100 + <td class="first b"><?php echo $emails; ?></td><td class="t"><?php _e('Distinct Emails', 'contact-forms'); ?></td>
101 + </tr>
102 + </table>
103 + <br />
104 + <span id="accua-forms-version"><a href="https://www.cimatti.it/wordpress/contact-forms/"><?php
105 + $plugin_data = get_plugin_data( ACCUA_FORMS_FILE );
106 + _e('Version', 'contact-forms'); echo " ".$plugin_data['Version']; ?></a> | <a href="admin.php?page=accua_forms" title="Contact Forms Dashboard"><?php _e('Dashboard', 'contact-forms'); ?></a>
107 + </span>
152 108
153 -<?php
109 + <?php
154 110 }
155 111
156 -function accua_forms_dashboard_page()
157 -{
158 - require_once ACCUA_FORMS_DIR . '/accua-forms-dashboard.php';
159 - return _accua_forms_dashboard_page();
112 +function accua_forms_dashboard_page(){
113 + require_once ACCUA_FORMS_DIR.'/accua-forms-dashboard.php';
114 + return _accua_forms_dashboard_page();
160 115 }
161 116
162 117
163 118 register_activation_hook(ACCUA_FORMS_FILE, 'accua_forms_install');
164 -function accua_forms_install()
165 -{
166 - static $ran = false;
167 - if ( $ran ) {
168 - return;
169 - }
170 - $ran = true;
171 -
119 +function accua_forms_install(){
120 + load_plugin_textdomain( 'contact-forms', false, ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH);
172 121 $modified = false;
173 122 $keys = get_option('accua_form_api_keys', array());
174 123 if (!isset($keys['hash'])) {
175 124 $modified = true;
176 - $keys['hash'] = wp_generate_password(64, true, true);
125 + $keys['hash'] = wp_generate_password(64,true,true);
177 126 }
178 127 if (!isset($keys['aes'])) {
179 128 $modified = true;
180 - $keys['aes'] = wp_generate_password(64, true, true);
129 + $keys['aes'] = wp_generate_password(64,true,true);
181 130 }
182 131 if ($modified) {
183 132 update_option('accua_form_api_keys', $keys);
184 133 }
@@ -184,14 +133,14 @@
184 133 }
185 134
186 135 global $wpdb;
187 136
188 - require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
137 + require_once(ABSPATH.'wp-admin/includes/upgrade.php');
189 138
190 139 $charset_collate = '';
191 - if (! empty($wpdb->charset))
140 + if ( ! empty($wpdb->charset) )
192 141 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
193 - if (! empty($wpdb->collate))
142 + if ( ! empty($wpdb->collate) )
194 143 $charset_collate .= " COLLATE $wpdb->collate";
195 144
196 145 $old_db_version = (int) get_option('accua_forms_db_version', 0);
197 146
@@ -196,11 +145,9 @@
196 145 $old_db_version = (int) get_option('accua_forms_db_version', 0);
197 146
198 147 if ($old_db_version < 3) {
199 148 $wpdb_suppress_errors_status = $wpdb->suppress_errors();
200 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- Schema migration, runs once
201 149 $wpdb->query("ALTER TABLE `{$wpdb->prefix}accua_forms_submissions` DROP INDEX uri");
202 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- Schema migration, runs once
203 150 $wpdb->query("ALTER TABLE `{$wpdb->prefix}accua_forms_submissions` DROP INDEX referrer");
204 151 $wpdb->suppress_errors($wpdb_suppress_errors_status);
205 152 }
206 153
@@ -208,16 +155,15 @@
208 155 afs_id BIGINT(20) NOT NULL AUTO_INCREMENT,
209 156 afs_form_id VARCHAR(77) NOT NULL DEFAULT '',
210 157 afs_post_id BIGINT(20) NOT NULL DEFAULT 0,
211 158 afs_ip VARCHAR(255) NOT NULL DEFAULT '',
212 - afs_uri TEXT NOT NULL,
213 - afs_referrer TEXT NOT NULL,
159 + afs_uri TEXT NOT NULL DEFAULT '',
160 + afs_referrer TEXT NOT NULL DEFAULT '',
214 161 afs_lang VARCHAR(60) NOT NULL DEFAULT '',
215 162 afs_created TIMESTAMP NOT NULL DEFAULT 0,
216 163 afs_submitted TIMESTAMP NOT NULL DEFAULT 0,
217 164 afs_status TINYINT(1) NOT NULL DEFAULT 0,
218 - afs_anonymized TINYINT(1) NOT NULL DEFAULT 0,
219 - afs_stats TEXT NOT NULL,
165 + afs_stats TEXT NOT NULL DEFAULT '',
220 166 afs_lead_status TINYINT(1) NOT NULL DEFAULT 0,
221 167 PRIMARY KEY (afs_id),
222 168 KEY form (afs_form_id, afs_status),
223 169 KEY uri (afs_uri(190)),
@@ -232,9 +178,9 @@
232 178 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_values` (
233 179 afsv_sub_id BIGINT(20) NOT NULL,
234 180 afsv_field_id VARCHAR(77) NOT NULL,
235 181 afsv_type varchar(255) NOT NULL DEFAULT '',
236 - afsv_value TEXT NOT NULL,
182 + afsv_value TEXT NOT NULL DEFAULT '',
237 183 PRIMARY KEY (afsv_sub_id, afsv_field_id),
238 184 KEY value_index (afsv_field_id(77), afsv_value(114))
239 185 ) $charset_collate;";
240 186 dbDelta($sql);
@@ -243,54 +189,19 @@
243 189 sono relative a una compilazione
244 190 possono esserci più note per ogni compilazione in date diverse
245 191
246 192 */
247 - $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_notes` (
193 + $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_notes` (
248 194 afsn_sub_id BIGINT(20) NOT NULL,
249 195 afsn_date TIMESTAMP NOT NULL DEFAULT 0,
250 - afsn_text TEXT NOT NULL,
196 + afsn_text TEXT NOT NULL DEFAULT '',
251 197 afsn_user VARCHAR(100) NOT NULL DEFAULT '',
252 198 PRIMARY KEY (afsn_sub_id, afsn_date),
253 199 KEY afsn_sub_id (afsn_sub_id)
254 200 ) $charset_collate;";
255 - dbDelta($sql);
201 + dbDelta($sql);
256 202
257 - // Data migration: run after dbDelta so new columns exist
258 - if ($old_db_version < 14) {
259 - // Migrate: afs_status=-2 (old "anonymized" status) → afs_anonymized=1 + restore original active status
260 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time migration
261 - $wpdb->query("UPDATE `{$wpdb->prefix}accua_forms_submissions` SET afs_anonymized = 1, afs_status = 0 WHERE afs_status = -2");
262 203
263 - // Migrate saved forms from 1.x format to 2.0 format
264 - $saved_forms = get_option('accua_forms_saved_forms', array());
265 - if (is_array($saved_forms)) {
266 - $forms_updated = false;
267 - foreach ($saved_forms as $fid => &$form) {
268 - // Rename legacy 'name' key to 'title' (changed in 2.0)
269 - if (isset($form['name']) && !isset($form['title'])) {
270 - $form['title'] = $form['name'];
271 - unset($form['name']);
272 - $forms_updated = true;
273 - }
274 - // Convert 'fields' from comma-separated string to array of instances
275 - if (isset($form['fields']) && is_string($form['fields'])) {
276 - $field_slugs = array_filter(array_map('trim', explode(',', $form['fields'])));
277 - $form['fields'] = array();
278 - foreach ($field_slugs as $slug) {
279 - $form['fields'][] = array('ref' => $slug);
280 - }
281 - unset($form['fieldnum']);
282 - $forms_updated = true;
283 - }
284 - }
285 - unset($form);
286 - if ($forms_updated) {
287 - update_option('accua_forms_saved_forms', $saved_forms);
288 - }
289 - }
290 - }
291 -
292 -
293 204 $avail_fields = get_option('accua_forms_avail_fields', array());
294 205
295 206 if (!is_array($avail_fields)) {
296 207 $avail_fields = array();
@@ -615,185 +526,38 @@
615 526 'description' => '',
616 527 'default_value' => '',
617 528 'allowed_values' => '',
618 529 ),
619 - 'turnstile' => array(
620 - 'id' => 'turnstile',
621 - 'name' => 'Turnstile',
622 - 'type' => 'turnstile',
623 - 'description' => '',
624 - 'default_value' => '',
625 - 'allowed_values' => '',
626 - ),
627 530 );
628 531 update_option('accua_forms_avail_fields', $avail_fields);
629 532 }
630 -
631 - // Add Turnstile field for existing installations (backward compatibility)
632 - // Only add if it doesn't exist yet
633 - if (!isset($avail_fields['turnstile'])) {
634 - $avail_fields['turnstile'] = array(
635 - 'id' => 'turnstile',
636 - 'name' => 'Turnstile',
637 - 'type' => 'turnstile',
638 - 'description' => '',
639 - 'default_value' => '',
640 - 'allowed_values' => '',
641 - );
642 - update_option('accua_forms_avail_fields', $avail_fields);
643 - }
644 533
645 - // Add Telephone field for existing installations (backward compatibility)
646 - // Only add if it doesn't exist yet
647 - if (!isset($avail_fields['telephone'])) {
648 - $avail_fields['telephone'] = array(
649 - 'id' => 'telephone',
650 - 'name' => 'Telephone',
651 - 'type' => 'telephone',
652 - 'description' => '',
653 - 'default_value' => '+39 ',
654 - 'allowed_values' => '',
655 - );
656 - update_option('accua_forms_avail_fields', $avail_fields);
657 - }
658 -
659 - $form_data = get_option('accua_forms_default_form_data', array());
534 + $form_data = get_option('accua_forms_default_form_data',array());
660 535 if (!is_array($form_data)) {
661 536 $form_data = array();
662 537 }
663 538
664 - // Use the centralized defaults function
665 - $form_data += accua_forms_get_default_form_data();
539 + $form_data += array(
540 + 'success_message' => '<div style="padding: 0px 30px 10px; background-color: #f4f4f4; border: 1px solid #ddd;">
541 +<h2>Thank you {first_name} {last_name},</h2>
542 +We have received your contact request. Check your inbox for the confirmation message.
666 543
667 - update_option('accua_forms_default_form_data', $form_data);
668 - update_option('accua_forms_db_version', ACCUA_FORMS_DB_VERSION);
669 -}
544 +<strong>Can\'t find the email?</strong>
670 545
671 -add_action('plugins_loaded', 'accua_forms_check_db_version_and_update', 9);
672 -function accua_forms_check_db_version_and_update()
673 -{
674 - if ( get_transient( '_accua_forms_data_deleted' ) ) {
675 - return;
676 - }
677 - $db_version = get_option('accua_forms_db_version', '');
678 - if (ACCUA_FORMS_DB_VERSION != $db_version) {
679 - accua_forms_install();
680 - }
681 -}
546 +It doesn\'t happen often but your mailbox could apply strict spam rules that block our email from reaching your inbox. Try checking your spam folder.
682 547
683 -add_filter('robots_txt', 'accua_forms_robots_txt', 10, 2);
684 -function accua_forms_robots_txt($output, $public)
685 -{
686 - if ($public) {
687 - $site_url = parse_url(site_url());
688 - $path = (!empty($site_url['path'])) ? $site_url['path'] : '';
689 - $output .= "\nUser-agent: *\n";
690 - $output .= "Allow: $path/wp-admin/js/\n";
691 - $output .= "Allow: $path/wp-admin/css/\n";
692 - }
693 - return $output;
694 -}
548 +Also check that the email you entered in the form (<strong>{email}</strong>) is correct. If it is not exact you can submit the form again.
695 549
696 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function with underscore prefix
697 -function _accua_forms_json_encode($item)
698 -{
699 - static $version = NULL;
700 - if ($version === NULL) {
701 - $version = version_compare(PHP_VERSION, '5.3.0', '>=');
702 - }
703 - if ($version) {
704 - return json_encode($item, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
705 - } else {
706 - return strtr(
707 - json_encode($item),
708 - array(
709 - '&' => '\\u0026',
710 - '<' => '\\u003C',
711 - '>' => '\\u003E',
712 - )
713 - );
714 - }
715 -}
550 +For other possible problems you may have encountered do not hesitate to contact us
716 551
717 -/* per ripulire eventuali token impostati nella versione 1.9.4 */
718 -function accua_forms_cleanup_meta_tokens()
719 -{
720 - global $wpdb;
721 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time cleanup on activation
722 - $post_ids = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_accua_download_token'");
723 -
724 - if (!empty($post_ids)) {
725 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time cleanup on activation
726 - $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_accua_download_token'");
727 - }
728 -}
729 -register_activation_hook(__FILE__, 'accua_forms_cleanup_meta_tokens');
730 -
731 -// Schedule retention cleanup cron on activation
732 -register_activation_hook( __FILE__, 'accua_forms_activate_retention_cron' );
733 -function accua_forms_activate_retention_cron() {
734 - if ( ! wp_next_scheduled( 'accua_forms_retention_cleanup' ) ) {
735 - wp_schedule_event( time(), 'daily', 'accua_forms_retention_cleanup' );
736 - }
737 -}
738 -
739 -// Clear retention cleanup cron on deactivation
740 -register_deactivation_hook( __FILE__, 'accua_forms_deactivate_retention_cron' );
741 -function accua_forms_deactivate_retention_cron() {
742 - wp_clear_scheduled_hook( 'accua_forms_retention_cleanup' );
743 -}
744 -
745 -// Add REST API compatibility
746 -add_action('rest_api_init', 'accua_forms_rest_compatibility');
747 -
748 -/**
749 - * Ensures proper REST API compatibility by closing any open PHP sessions
750 - * This prevents timeouts when WordPress is making internal REST API requests
751 - */
752 -function accua_forms_rest_compatibility()
753 -{
754 - // Check if a session is active and close it for REST requests
755 - if (session_id() && session_status() === PHP_SESSION_ACTIVE) {
756 - session_write_close();
757 - }
758 -
759 - // Remove hooks that might interfere with REST API requests
760 - remove_action('init', 'accua_forms_init_session', 1);
761 -}
762 -
763 -/**
764 - * Get the default form data values.
765 - *
766 - * This function returns all default values for form settings including messages,
767 - * email templates, and styling options. Used during installation and for the
768 - * "Restore to Default" functionality in the settings page.
769 - *
770 - * @since 2.0.0-beta.6
771 - * @return array Default form data values.
772 - */
773 -function accua_forms_get_default_form_data()
774 -{
775 - return array(
776 - 'success_message' => '<div style="font-family: Arial, Helvetica, sans-serif;">
777 -<h2>' . __('Thank you', 'contact-forms') . ' {first_name} {last_name},</h2>
778 -' . __('We have received your contact request. Check your inbox for the confirmation message.', 'contact-forms') . '
779 -
780 -<strong>' . __('Can\'t find the email?', 'contact-forms') . '</strong>
781 -
782 -' . __('It doesn\'t happen often but your mailbox could apply strict spam rules that block our email from reaching your inbox. Try checking your spam folder.', 'contact-forms') . '
783 -
784 -' . __('Also check that the email you entered in the form', 'contact-forms') . ' (<strong>{email}</strong>) ' . __('is correct. If it is not, you can submit the form again.', 'contact-forms') . '
785 -
786 -' . __('For any other issues, please don\'t hesitate to contact us.', 'contact-forms') . '
787 -
788 552 </div>',
789 - 'error_message' => '<div style="font-family: Arial, Helvetica, sans-serif;">
790 -<h2>' . __('Oops! Something went wrong.', 'contact-forms') . '</h2>
791 -' . __('Internet is an awfully complex place and even though we take every precaution to make sure things run smoothly every once in a while things can go wrong that are not under our control.', 'contact-forms') . '
553 + 'error_message' => '<div style="padding: 0px 30px 10px; background-color: #f4f4f4; border: 1px solid #ddd;">
554 +<h2>Oops! Something went wrong.</h2>
555 +Internet is an awfully complex place and even though we take every precaution to make sure things run smoothly every once in a while things can go wrong that are not under our control.
792 556
793 -' . __('Please try filling in the form again.', 'contact-forms') . '
557 +Please try filling in the form again.
794 558
795 -' . __('For any other issues, please don\'t hesitate to contact us.', 'contact-forms') . '
559 +For other possible problems you may have encountered do not hesitate to contact us
796 560
797 561 </div>',
798 562 'emails_from_name' => '',
799 563 'emails_from' => '',
@@ -798,10 +562,10 @@
798 562 'emails_from_name' => '',
799 563 'emails_from' => '',
800 564 'admin_emails_to' => get_option('admin_email', ''),
801 565 'emails_bcc' => '',
802 - 'admin_emails_subject' => __('New contact request from your site', 'contact-forms'),
803 - 'admin_emails_message' => '<table style="font-family: Arial, Helvetica, sans-serif; background: #fff; margin-top: 10px; border: 1px solid #DDDDDD; max-width: 700px;" cellspacing="0" cellpadding="0" align="center">
566 + 'admin_emails_subject' => 'A contact from your site',
567 + 'admin_emails_message' => '<table style="font-family: \'Lucida Sans\',\'Lucida Grande\', Verdana, Arial, Sans-Serif !important; background: #fff; margin-top: 10px; border: 1px solid #DDDDDD; max-width: 700px;" cellspacing="0" cellpadding="0" align="center">
804 568 <tbody>
805 569 <tr>
806 570 <td>
807 571 <table style="max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center">
@@ -807,40 +571,40 @@
807 571 <table style="max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center">
808 572 <tbody>
809 573 <tr>
810 574 <td>
811 -<table style="padding: 10px; border: 1px solid #dfdfdf; max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center">
575 +<table style="padding: 10px; background-color: #f4f4f4; border: 1px solid #ddd; max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
812 576 <tbody>
813 577 <tr valign="top">
814 578 <td style="max-width:22px;"></td>
815 -<td style="font-family: Arial, Helvetica, sans-serif; padding: 0px 30px 10px; max-width: 645px;">
816 -<table style="width: 100%; table-layout: fixed;">
579 +<td style="font-family: \'Lucida Sans\',\'Lucida Grande\', Verdana, Arial, Sans-Serif !important; padding: 0px 30px 10px; max-width: 645px;">
580 +<table>
817 581 <tbody>
818 582 <tr>
819 -<td>' . __('On', 'contact-forms') . ' {__submitted_day_month_year} ' . __('at', 'contact-forms') . ' {__submitted_hour} ' . __('the following form was filled in.', 'contact-forms') . '
583 +<td>On {__submitted_day_month_year} at {__submitted_hour} the following form was filled in.
820 584
821 585 <hr />
822 586
823 -<strong>' . __('Page where the form was filled in', 'contact-forms') . '</strong>
824 -<a href="{__url}" style="word-break: break-all; overflow-wrap: break-word;">{__url}</a></td>
587 +<strong>Page where the form was filled in</strong>
588 +<a href="{__url}">{__url}</a></td>
825 589 </tr>
826 590 <tr><td>
827 -<strong>' . __('Submission review page', 'contact-forms') . '</strong>
828 -<a href="{__review_submission_url}" style="word-break: break-all; overflow-wrap: break-word;">{__review_submission_url}</a>
591 +<strong>Submission review page</strong>
592 +<a href="{__review_submission_url}">{__review_submission_url}</a>
829 593 </td></tr>
830 594 <tr>
831 -<td id="submitted_html" style="overflow-wrap: break-word; word-break: normal;">{__submitted_html}</td>
595 +<td id="submitted_html">{__submitted_html}</td>
832 596 </tr>
833 597 <tr>
834 -<td>[form_if {__referrer} [<strong>' . __('Referrer', 'contact-forms') . '</strong> - ' . __('where the visitor came from', 'contact-forms') . ' <em>' . __('before reaching the page', 'contact-forms') . '</em>:<br /><span style="word-break: break-all; overflow-wrap: break-word;">{__referrer}</span>]]</td>
598 +<td>[form_if {__referrer} [<strong>Referrer</strong> - where did the contact come from <em>before reaching the page</em>: {__referrer}]]</td>
835 599 </tr>
836 600 <tr>
837 -<td><strong>' . __('Contact IP', 'contact-forms') . '</strong> {__anonymized_ip}
601 +<td><strong>Contact IP</strong> {__anonymized_ip}
838 602 <hr />
839 603 </td>
840 604 </tr>
841 605 <tr>
842 -<td>[form_if {__autoreply} [' . __('A confirmation email was sent to', 'contact-forms') . ' <a href="mailto:{email}">{email}</a> ' . __('with the following message', 'contact-forms') . ':
606 +<td>[form_if {__autoreply} [The contact received in his email <a href="mailto:{email}">{email}</a> the following confirmation message:
843 607 <table>
844 608 <tbody>
845 609 <tr>
846 610 <td>{__confirmation_emails_message}</td>
@@ -863,19 +627,19 @@
863 627 </td>
864 628 </tr>
865 629 </tbody>
866 630 </table>',
867 - 'confirmation_emails_subject' => __('Your message', 'contact-forms'),
868 - 'confirmation_emails_message' => '<div style="font-family: Arial, Helvetica, sans-serif;">
631 + 'confirmation_emails_subject' => 'Your message',
632 + 'confirmation_emails_message' => '<div>
869 633
870 -<h2>' . __('Thank you', 'contact-forms') . ' {first_name} {last_name},</h2>
871 -' . __('Thank you for your contact request.', 'contact-forms') . '
634 +<h2>Thank you {first_name} {last_name},</h2>
635 +Thank Your for your contact request.
872 636
873 -' . __('We will contact you as soon as possible.', 'contact-forms') . '
637 +We will contact you as soon as possible.
874 638
875 -' . __('Sincerely,', 'contact-forms') . '
639 +Sincerely,
876 640
877 -' . __('The Website Team', 'contact-forms') . '
641 +The Website Team
878 642
879 643 <hr />
880 644 </div>',
881 645
@@ -902,83 +666,46 @@
902 666 'style_submit_padding' => '',
903 667 'style_submit_color' => '',
904 668 'style_submit_font_size' => '',
905 669 );
670 +
671 + update_option('accua_forms_default_form_data', $form_data);
672 + update_option('accua_forms_db_version', ACCUA_FORMS_DB_VERSION);
906 673 }
907 674
908 -/**
909 - * Get all countries with localized names for phone field country selector.
910 - *
911 - * Uses PHP Intl extension to generate localized country names from ISO 3166-1 alpha-2 codes.
912 - * Falls back to country codes if Intl extension is unavailable.
913 - *
914 - * @since 2.0.0-beta.34
915 - * @param string|null $display_locale Locale for display names (default: current WordPress locale).
916 - * @return array Associative array ['US' => 'United States', 'IT' => 'Italy', ...] sorted alphabetically.
917 - */
918 -function accua_forms_get_countries( $display_locale = null ) {
919 - // ISO 3166-1 alpha-2 codes - complete list (249 countries/territories)
920 - $country_codes = array(
921 - 'AF', 'AX', 'AL', 'DZ', 'AS', 'AD', 'AO', 'AI', 'AQ', 'AG', 'AR', 'AM', 'AW', 'AU', 'AT', 'AZ',
922 - 'BS', 'BH', 'BD', 'BB', 'BY', 'BE', 'BZ', 'BJ', 'BM', 'BT', 'BO', 'BQ', 'BA', 'BW', 'BV', 'BR',
923 - 'IO', 'BN', 'BG', 'BF', 'BI', 'KH', 'CM', 'CA', 'CV', 'KY', 'CF', 'TD', 'CL', 'CN', 'CX', 'CC',
924 - 'CO', 'KM', 'CG', 'CD', 'CK', 'CR', 'CI', 'HR', 'CU', 'CW', 'CY', 'CZ', 'DK', 'DJ', 'DM', 'DO',
925 - 'EC', 'EG', 'SV', 'GQ', 'ER', 'EE', 'ET', 'FK', 'FO', 'FJ', 'FI', 'FR', 'GF', 'PF', 'TF', 'GA',
926 - 'GM', 'GE', 'DE', 'GH', 'GI', 'GR', 'GL', 'GD', 'GP', 'GU', 'GT', 'GG', 'GN', 'GW', 'GY', 'HT',
927 - 'HM', 'VA', 'HN', 'HK', 'HU', 'IS', 'IN', 'ID', 'IR', 'IQ', 'IE', 'IM', 'IL', 'IT', 'JM', 'JP',
928 - 'JE', 'JO', 'KZ', 'KE', 'KI', 'KP', 'KR', 'KW', 'KG', 'LA', 'LV', 'LB', 'LS', 'LR', 'LY', 'LI',
929 - 'LT', 'LU', 'MO', 'MK', 'MG', 'MW', 'MY', 'MV', 'ML', 'MT', 'MH', 'MQ', 'MR', 'MU', 'YT', 'MX',
930 - 'FM', 'MD', 'MC', 'MN', 'ME', 'MS', 'MA', 'MZ', 'MM', 'NA', 'NR', 'NP', 'NL', 'NC', 'NZ', 'NI',
931 - 'NE', 'NG', 'NU', 'NF', 'MP', 'NO', 'OM', 'PK', 'PW', 'PS', 'PA', 'PG', 'PY', 'PE', 'PH', 'PN',
932 - 'PL', 'PT', 'PR', 'QA', 'RE', 'RO', 'RU', 'RW', 'BL', 'SH', 'KN', 'LC', 'MF', 'PM', 'VC', 'WS',
933 - 'SM', 'ST', 'SA', 'SN', 'RS', 'SC', 'SL', 'SG', 'SX', 'SK', 'SI', 'SB', 'SO', 'ZA', 'GS', 'SS',
934 - 'ES', 'LK', 'SD', 'SR', 'SJ', 'SZ', 'SE', 'CH', 'SY', 'TW', 'TJ', 'TZ', 'TH', 'TL', 'TG', 'TK',
935 - 'TO', 'TT', 'TN', 'TR', 'TM', 'TC', 'TV', 'UG', 'UA', 'AE', 'GB', 'US', 'UM', 'UY', 'UZ', 'VU',
936 - 'VE', 'VN', 'VG', 'VI', 'WF', 'EH', 'YE', 'ZM', 'ZW',
937 - );
675 +add_action('plugins_loaded', 'accua_forms_check_db_version_and_update', 9);
676 +function accua_forms_check_db_version_and_update() {
677 + $db_version = get_option('accua_forms_db_version', '');
678 + if (ACCUA_FORMS_DB_VERSION != $db_version) {
679 + accua_forms_install();
680 + }
681 +}
938 682
939 - // Use WordPress locale if not specified
940 - if ( null === $display_locale ) {
941 - $display_locale = get_locale();
683 +add_filter( 'robots_txt', 'accua_forms_robots_txt', 10, 2);
684 +function accua_forms_robots_txt($output, $public) {
685 + if ($public) {
686 + $site_url = parse_url( site_url() );
687 + $path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';
688 + $output .= "\nUser-agent: *\n";
689 + $output .= "Allow: $path/wp-admin/js/\n";
690 + $output .= "Allow: $path/wp-admin/css/\n";
942 691 }
692 + return $output;
693 +}
943 694
944 - // Check if Intl extension is available
945 - if ( ! class_exists( 'Locale' ) ) {
946 - // Fallback: return codes as both key and value
947 - return array_combine( $country_codes, $country_codes );
695 +function _accua_forms_json_encode($item) {
696 + static $version = NULL;
697 + if ($version === NULL) {
698 + $version = version_compare(PHP_VERSION, '5.3.0', '>=');
948 699 }
949 -
950 - $countries = array();
951 - foreach ( $country_codes as $code ) {
952 - // The trick: prepend '-' to convert region code to locale format
953 - $name = Locale::getDisplayRegion( '-' . $code, $display_locale );
954 - // If Intl returns the code itself (unknown region), use the code
955 - $countries[ $code ] = ( $name && $name !== $code ) ? $name : $code;
700 + if ($version) {
701 + return json_encode($item, JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP);
702 + } else {
703 + return strtr(json_encode($item),
704 + array(
705 + '&' => '\\u0026',
706 + '<' => '\\u003C',
707 + '>' => '\\u003E',
708 + ));
956 709 }
957 -
958 - // Sort alphabetically by localized name
959 - asort( $countries, SORT_LOCALE_STRING );
960 -
961 - return $countries;
962 710 }
963 711
964 -/**
965 - * Get the translated label for a layout value.
966 - *
967 - * Returns the human-readable, translated label for a given layout value.
968 - * Used in layout dropdowns throughout the admin interface.
969 - *
970 - * @since 2.0.0-beta.29
971 - * @param string $layout Layout value: 'sidebyside', 'toplabel', or 'inlinelabel'.
972 - * @return string Translated layout label.
973 - */
974 -function accua_forms_get_layout_label( $layout ) {
975 - switch ( $layout ) {
976 - case 'toplabel':
977 - return __( 'Labels on top of the fields', 'contact-forms' );
978 - case 'inlinelabel':
979 - return __( 'Inline labels', 'contact-forms' );
980 - case 'sidebyside':
981 - default:
982 - return __( 'Labels on the left of the fields', 'contact-forms' );
983 - }
984 -}