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 +146 -363 2.2.321.9.2 View file →
@@ -1,22 +1,22 @@
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.32
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 -Requires at least: 5.9
11 +Requires at least: 3.5
12 12 License: GPLv2 or later
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,37 +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', 192);
43 -define('ACCUA_FORMS_JS_VERSION', '118');
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 -require_once('admin/shortcode-button.php');
51 -require_once('admin/theme-helper.php');
52 -require_once('block-editor.php');
48 +require_once('accua-shortcode-button.php');
53 49
54 -function accua_forms_dashboard_page_head()
55 -{
50 +function accua_forms_dashboard_page_head(){
56 51 $screen = get_current_screen();
57 - $screen->add_help_tab(array(
58 - 'id' => 'accua_help_tab',
59 - 'title' => __('Contact Forms Dashboard', 'contact-forms'),
60 - 'content' => '<p>' . __('Marketing tools for WordPress', 'contact-forms') . '</p>',
61 - ));
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 + ) );
62 57
63 - wp_enqueue_script( 'accua-forms-expandable-cells', plugins_url( 'assets/js/admin/expandable-cells.js', ACCUA_FORMS_FILE ), array(), ACCUA_FORMS_JS_VERSION, true );
64 - 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);
65 - 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);
66 62
67 - /* Tentativo x drag and drop
63 + /* Tentativo x drag and drop
68 64 $page_hook_id = fx_smb_setings_page_id();
69 65 /* Load the JavaScript needed for the settings screen. * /
70 66 add_action( 'admin_enqueue_scripts', 'fx_smb_enqueue_scripts' );
71 67 add_action( "admin_footer-{$page_hook_id}", 'fx_smb_footer_scripts' );
@@ -74,52 +70,64 @@
74 70 add_filter( 'screen_layout_columns', 'fx_smb_screen_layout_column', 10, 2 );
75 71 */
76 72 }
77 73
78 -/**
79 - * Add Contact Forms dashboard widget.
80 - *
81 - * Only visible to users with the 'manage_options' capability, the same
82 - * capability required by the plugin admin pages. wp_dashboard_setup only
83 - * fires on the dashboard screen, and the widget code is loaded on demand
84 - * here, so admin/dashboard-widget.php is never included on the frontend
85 - * or on other admin pages.
86 - */
87 -add_action('wp_dashboard_setup', 'accua_contact_forms_dashboard_add_widgets');
88 -function accua_contact_forms_dashboard_add_widgets()
89 -{
90 - if (!current_user_can('manage_options')) {
91 - return;
92 - }
93 - require_once ACCUA_FORMS_DIR . '/admin/dashboard-widget.php';
94 - wp_add_dashboard_widget('accua_contact_forms_dashboard_widget_news', __('Contact Forms', 'contact-forms'), 'accua_contact_forms_dashboard_widget_news_handler');
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' );
95 80 }
96 81
97 -function accua_forms_dashboard_page()
98 -{
99 - require_once ACCUA_FORMS_DIR . '/admin/dashboard-page.php';
100 - return _accua_forms_dashboard_page();
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>
108 +
109 + <?php
101 110 }
102 111
112 +function accua_forms_dashboard_page(){
113 + require_once ACCUA_FORMS_DIR.'/accua-forms-dashboard.php';
114 + return _accua_forms_dashboard_page();
115 +}
103 116
117 +
104 118 register_activation_hook(ACCUA_FORMS_FILE, 'accua_forms_install');
105 -function accua_forms_install()
106 -{
107 - static $ran = false;
108 - if ( $ran ) {
109 - return;
110 - }
111 - $ran = true;
112 -
119 +function accua_forms_install(){
120 + load_plugin_textdomain( 'contact-forms', false, ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH);
113 121 $modified = false;
114 122 $keys = get_option('accua_form_api_keys', array());
115 123 if (!isset($keys['hash'])) {
116 124 $modified = true;
117 - $keys['hash'] = wp_generate_password(64, true, true);
125 + $keys['hash'] = wp_generate_password(64,true,true);
118 126 }
119 127 if (!isset($keys['aes'])) {
120 128 $modified = true;
121 - $keys['aes'] = wp_generate_password(64, true, true);
129 + $keys['aes'] = wp_generate_password(64,true,true);
122 130 }
123 131 if ($modified) {
124 132 update_option('accua_form_api_keys', $keys);
125 133 }
@@ -125,14 +133,14 @@
125 133 }
126 134
127 135 global $wpdb;
128 136
129 - require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
137 + require_once(ABSPATH.'wp-admin/includes/upgrade.php');
130 138
131 139 $charset_collate = '';
132 - if (! empty($wpdb->charset))
140 + if ( ! empty($wpdb->charset) )
133 141 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
134 - if (! empty($wpdb->collate))
142 + if ( ! empty($wpdb->collate) )
135 143 $charset_collate .= " COLLATE $wpdb->collate";
136 144
137 145 $old_db_version = (int) get_option('accua_forms_db_version', 0);
138 146
@@ -137,11 +145,9 @@
137 145 $old_db_version = (int) get_option('accua_forms_db_version', 0);
138 146
139 147 if ($old_db_version < 3) {
140 148 $wpdb_suppress_errors_status = $wpdb->suppress_errors();
141 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- Schema migration, runs once
142 149 $wpdb->query("ALTER TABLE `{$wpdb->prefix}accua_forms_submissions` DROP INDEX uri");
143 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- Schema migration, runs once
144 150 $wpdb->query("ALTER TABLE `{$wpdb->prefix}accua_forms_submissions` DROP INDEX referrer");
145 151 $wpdb->suppress_errors($wpdb_suppress_errors_status);
146 152 }
147 153
@@ -149,16 +155,15 @@
149 155 afs_id BIGINT(20) NOT NULL AUTO_INCREMENT,
150 156 afs_form_id VARCHAR(77) NOT NULL DEFAULT '',
151 157 afs_post_id BIGINT(20) NOT NULL DEFAULT 0,
152 158 afs_ip VARCHAR(255) NOT NULL DEFAULT '',
153 - afs_uri TEXT NOT NULL,
154 - afs_referrer TEXT NOT NULL,
159 + afs_uri TEXT NOT NULL DEFAULT '',
160 + afs_referrer TEXT NOT NULL DEFAULT '',
155 161 afs_lang VARCHAR(60) NOT NULL DEFAULT '',
156 162 afs_created TIMESTAMP NOT NULL DEFAULT 0,
157 163 afs_submitted TIMESTAMP NOT NULL DEFAULT 0,
158 164 afs_status TINYINT(1) NOT NULL DEFAULT 0,
159 - afs_anonymized TINYINT(1) NOT NULL DEFAULT 0,
160 - afs_stats TEXT NOT NULL,
165 + afs_stats TEXT NOT NULL DEFAULT '',
161 166 afs_lead_status TINYINT(1) NOT NULL DEFAULT 0,
162 167 PRIMARY KEY (afs_id),
163 168 KEY form (afs_form_id, afs_status),
164 169 KEY uri (afs_uri(190)),
@@ -173,9 +178,9 @@
173 178 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_values` (
174 179 afsv_sub_id BIGINT(20) NOT NULL,
175 180 afsv_field_id VARCHAR(77) NOT NULL,
176 181 afsv_type varchar(255) NOT NULL DEFAULT '',
177 - afsv_value TEXT NOT NULL,
182 + afsv_value TEXT NOT NULL DEFAULT '',
178 183 PRIMARY KEY (afsv_sub_id, afsv_field_id),
179 184 KEY value_index (afsv_field_id(77), afsv_value(114))
180 185 ) $charset_collate;";
181 186 dbDelta($sql);
@@ -184,54 +189,19 @@
184 189 sono relative a una compilazione
185 190 possono esserci più note per ogni compilazione in date diverse
186 191
187 192 */
188 - $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_notes` (
193 + $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_notes` (
189 194 afsn_sub_id BIGINT(20) NOT NULL,
190 195 afsn_date TIMESTAMP NOT NULL DEFAULT 0,
191 - afsn_text TEXT NOT NULL,
196 + afsn_text TEXT NOT NULL DEFAULT '',
192 197 afsn_user VARCHAR(100) NOT NULL DEFAULT '',
193 198 PRIMARY KEY (afsn_sub_id, afsn_date),
194 199 KEY afsn_sub_id (afsn_sub_id)
195 200 ) $charset_collate;";
196 - dbDelta($sql);
201 + dbDelta($sql);
197 202
198 - // Data migration: run after dbDelta so new columns exist
199 - if ($old_db_version < 14) {
200 - // Migrate: afs_status=-2 (old "anonymized" status) → afs_anonymized=1 + restore original active status
201 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time migration
202 - $wpdb->query("UPDATE `{$wpdb->prefix}accua_forms_submissions` SET afs_anonymized = 1, afs_status = 0 WHERE afs_status = -2");
203 203
204 - // Migrate saved forms from 1.x format to 2.0 format
205 - $saved_forms = get_option('accua_forms_saved_forms', array());
206 - if (is_array($saved_forms)) {
207 - $forms_updated = false;
208 - foreach ($saved_forms as $fid => &$form) {
209 - // Rename legacy 'name' key to 'title' (changed in 2.0)
210 - if (isset($form['name']) && !isset($form['title'])) {
211 - $form['title'] = $form['name'];
212 - unset($form['name']);
213 - $forms_updated = true;
214 - }
215 - // Convert 'fields' from comma-separated string to array of instances
216 - if (isset($form['fields']) && is_string($form['fields'])) {
217 - $field_slugs = array_filter(array_map('trim', explode(',', $form['fields'])));
218 - $form['fields'] = array();
219 - foreach ($field_slugs as $slug) {
220 - $form['fields'][] = array('ref' => $slug);
221 - }
222 - unset($form['fieldnum']);
223 - $forms_updated = true;
224 - }
225 - }
226 - unset($form);
227 - if ($forms_updated) {
228 - update_option('accua_forms_saved_forms', $saved_forms);
229 - }
230 - }
231 - }
232 -
233 -
234 204 $avail_fields = get_option('accua_forms_avail_fields', array());
235 205
236 206 if (!is_array($avail_fields)) {
237 207 $avail_fields = array();
@@ -556,188 +526,38 @@
556 526 'description' => '',
557 527 'default_value' => '',
558 528 'allowed_values' => '',
559 529 ),
560 - 'turnstile' => array(
561 - 'id' => 'turnstile',
562 - 'name' => 'Turnstile',
563 - 'type' => 'turnstile',
564 - 'description' => '',
565 - 'default_value' => '',
566 - 'allowed_values' => '',
567 - ),
568 530 );
569 531 update_option('accua_forms_avail_fields', $avail_fields);
570 532 }
571 -
572 - // Add Turnstile field for existing installations (backward compatibility)
573 - // Only add if it doesn't exist yet
574 - if (!isset($avail_fields['turnstile'])) {
575 - $avail_fields['turnstile'] = array(
576 - 'id' => 'turnstile',
577 - 'name' => 'Turnstile',
578 - 'type' => 'turnstile',
579 - 'description' => '',
580 - 'default_value' => '',
581 - 'allowed_values' => '',
582 - );
583 - update_option('accua_forms_avail_fields', $avail_fields);
584 - }
585 533
586 - // Add Telephone field for existing installations (backward compatibility)
587 - // Only add if it doesn't exist yet
588 - if (!isset($avail_fields['telephone'])) {
589 - $avail_fields['telephone'] = array(
590 - 'id' => 'telephone',
591 - 'name' => 'Telephone',
592 - 'type' => 'telephone',
593 - 'description' => '',
594 - 'default_value' => '+39 ',
595 - 'allowed_values' => '',
596 - );
597 - update_option('accua_forms_avail_fields', $avail_fields);
598 - }
599 -
600 - $form_data = get_option('accua_forms_default_form_data', array());
534 + $form_data = get_option('accua_forms_default_form_data',array());
601 535 if (!is_array($form_data)) {
602 536 $form_data = array();
603 537 }
604 538
605 - // Use the centralized defaults function
606 - $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.
607 543
608 - update_option('accua_forms_default_form_data', $form_data);
609 - update_option('accua_forms_db_version', ACCUA_FORMS_DB_VERSION);
610 -}
544 +<strong>Can\'t find the email?</strong>
611 545
612 -// Runs at init priority 1 (before accua_form_init at priority 5) so the DB schema
613 -// is always up to date before form processing begins. Also ensures translations used
614 -// in accua_forms_get_default_form_data() are loaded when a fresh install is detected.
615 -add_action('init', 'accua_forms_check_db_version_and_update', 1);
616 -function accua_forms_check_db_version_and_update()
617 -{
618 - if ( get_transient( '_accua_forms_data_deleted' ) ) {
619 - return;
620 - }
621 - $db_version = get_option('accua_forms_db_version', '');
622 - if (ACCUA_FORMS_DB_VERSION != $db_version) {
623 - accua_forms_install();
624 - }
625 -}
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.
626 547
627 -add_filter('robots_txt', 'accua_forms_robots_txt', 10, 2);
628 -function accua_forms_robots_txt($output, $public)
629 -{
630 - if ($public) {
631 - $site_url = wp_parse_url(site_url());
632 - $path = (!empty($site_url['path'])) ? $site_url['path'] : '';
633 - $output .= "\nUser-agent: *\n";
634 - $output .= "Allow: $path/wp-admin/js/\n";
635 - $output .= "Allow: $path/wp-admin/css/\n";
636 - }
637 - return $output;
638 -}
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.
639 549
640 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function with underscore prefix
641 -function _accua_forms_json_encode($item)
642 -{
643 - static $version = NULL;
644 - if ($version === NULL) {
645 - $version = version_compare(PHP_VERSION, '5.3.0', '>=');
646 - }
647 - if ($version) {
648 - return json_encode($item, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
649 - } else {
650 - return strtr(
651 - json_encode($item),
652 - array(
653 - '&' => '\\u0026',
654 - '<' => '\\u003C',
655 - '>' => '\\u003E',
656 - )
657 - );
658 - }
659 -}
550 +For other possible problems you may have encountered do not hesitate to contact us
660 551
661 -/* per ripulire eventuali token impostati nella versione 1.9.4 */
662 -function accua_forms_cleanup_meta_tokens()
663 -{
664 - global $wpdb;
665 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time cleanup on activation
666 - $post_ids = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_accua_download_token'");
667 -
668 - if (!empty($post_ids)) {
669 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time cleanup on activation
670 - $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_accua_download_token'");
671 - }
672 -}
673 -register_activation_hook(__FILE__, 'accua_forms_cleanup_meta_tokens');
674 -
675 -// Schedule retention cleanup cron on activation
676 -register_activation_hook( __FILE__, 'accua_forms_activate_retention_cron' );
677 -function accua_forms_activate_retention_cron() {
678 - if ( ! wp_next_scheduled( 'accua_forms_retention_cleanup' ) ) {
679 - wp_schedule_event( time(), 'daily', 'accua_forms_retention_cleanup' );
680 - }
681 -}
682 -
683 -// Clear retention cleanup cron on deactivation
684 -register_deactivation_hook( __FILE__, 'accua_forms_deactivate_retention_cron' );
685 -function accua_forms_deactivate_retention_cron() {
686 - wp_clear_scheduled_hook( 'accua_forms_retention_cleanup' );
687 -}
688 -
689 -// Add REST API compatibility
690 -add_action('rest_api_init', 'accua_forms_rest_compatibility');
691 -
692 -/**
693 - * Ensures proper REST API compatibility by closing any open PHP sessions
694 - * This prevents timeouts when WordPress is making internal REST API requests
695 - */
696 -function accua_forms_rest_compatibility()
697 -{
698 - // Check if a session is active and close it for REST requests
699 - if (session_id() && session_status() === PHP_SESSION_ACTIVE) {
700 - session_write_close();
701 - }
702 -
703 - // Remove hooks that might interfere with REST API requests
704 - remove_action('init', 'accua_forms_init_session', 1);
705 -}
706 -
707 -/**
708 - * Get the default form data values.
709 - *
710 - * This function returns all default values for form settings including messages,
711 - * email templates, and styling options. Used during installation and for the
712 - * "Restore to Default" functionality in the settings page.
713 - *
714 - * @since 2.0.0-beta.6
715 - * @return array Default form data values.
716 - */
717 -function accua_forms_get_default_form_data()
718 -{
719 - return array(
720 - 'success_message' => '<div style="font-family: Arial, Helvetica, sans-serif;">
721 -<h2>' . __('Thank you', 'contact-forms') . ' {first_name} {last_name},</h2>
722 -' . __('We have received your contact request. Check your inbox for the confirmation message.', 'contact-forms') . '
723 -
724 -<strong>' . __('Can\'t find the email?', 'contact-forms') . '</strong>
725 -
726 -' . __('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') . '
727 -
728 -' . __('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') . '
729 -
730 -' . __('For any other issues, please don\'t hesitate to contact us.', 'contact-forms') . '
731 -
732 552 </div>',
733 - 'error_message' => '<div style="font-family: Arial, Helvetica, sans-serif;">
734 -<h2>' . __('Oops! Something went wrong.', 'contact-forms') . '</h2>
735 -' . __('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.
736 556
737 -' . __('Please try filling in the form again.', 'contact-forms') . '
557 +Please try filling in the form again.
738 558
739 -' . __('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
740 560
741 561 </div>',
742 562 'emails_from_name' => '',
743 563 'emails_from' => '',
@@ -742,10 +562,10 @@
742 562 'emails_from_name' => '',
743 563 'emails_from' => '',
744 564 'admin_emails_to' => get_option('admin_email', ''),
745 565 'emails_bcc' => '',
746 - 'admin_emails_subject' => __('New contact request from your site', 'contact-forms'),
747 - '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">
748 568 <tbody>
749 569 <tr>
750 570 <td>
751 571 <table style="max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center">
@@ -751,40 +571,40 @@
751 571 <table style="max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center">
752 572 <tbody>
753 573 <tr>
754 574 <td>
755 -<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">
756 576 <tbody>
757 577 <tr valign="top">
758 578 <td style="max-width:22px;"></td>
759 -<td style="font-family: Arial, Helvetica, sans-serif; padding: 0px 30px 10px; max-width: 645px;">
760 -<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>
761 581 <tbody>
762 582 <tr>
763 -<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.
764 584
765 585 <hr />
766 586
767 -<strong>' . __('Page where the form was filled in', 'contact-forms') . '</strong>
768 -<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>
769 589 </tr>
770 590 <tr><td>
771 -<strong>' . __('Submission review page', 'contact-forms') . '</strong>
772 -<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>
773 593 </td></tr>
774 594 <tr>
775 -<td id="submitted_html" style="overflow-wrap: break-word; word-break: normal;">{__submitted_html}</td>
595 +<td id="submitted_html">{__submitted_html}</td>
776 596 </tr>
777 597 <tr>
778 -<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>
779 599 </tr>
780 600 <tr>
781 -<td><strong>' . __('Contact IP', 'contact-forms') . '</strong> {__anonymized_ip}
601 +<td><strong>Contact IP</strong> {__anonymized_ip}
782 602 <hr />
783 603 </td>
784 604 </tr>
785 605 <tr>
786 -<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:
787 607 <table>
788 608 <tbody>
789 609 <tr>
790 610 <td>{__confirmation_emails_message}</td>
@@ -807,19 +627,19 @@
807 627 </td>
808 628 </tr>
809 629 </tbody>
810 630 </table>',
811 - 'confirmation_emails_subject' => __('Your message', 'contact-forms'),
812 - 'confirmation_emails_message' => '<div style="font-family: Arial, Helvetica, sans-serif;">
631 + 'confirmation_emails_subject' => 'Your message',
632 + 'confirmation_emails_message' => '<div>
813 633
814 -<h2>' . __('Thank you', 'contact-forms') . ' {first_name} {last_name},</h2>
815 -' . __('Thank you for your contact request.', 'contact-forms') . '
634 +<h2>Thank you {first_name} {last_name},</h2>
635 +Thank Your for your contact request.
816 636
817 -' . __('We will contact you as soon as possible.', 'contact-forms') . '
637 +We will contact you as soon as possible.
818 638
819 -' . __('Sincerely,', 'contact-forms') . '
639 +Sincerely,
820 640
821 -' . __('The Website Team', 'contact-forms') . '
641 +The Website Team
822 642
823 643 <hr />
824 644 </div>',
825 645
@@ -846,83 +666,46 @@
846 666 'style_submit_padding' => '',
847 667 'style_submit_color' => '',
848 668 'style_submit_font_size' => '',
849 669 );
670 +
671 + update_option('accua_forms_default_form_data', $form_data);
672 + update_option('accua_forms_db_version', ACCUA_FORMS_DB_VERSION);
850 673 }
851 674
852 -/**
853 - * Get all countries with localized names for phone field country selector.
854 - *
855 - * Uses PHP Intl extension to generate localized country names from ISO 3166-1 alpha-2 codes.
856 - * Falls back to country codes if Intl extension is unavailable.
857 - *
858 - * @since 2.0.0-beta.34
859 - * @param string|null $display_locale Locale for display names (default: current WordPress locale).
860 - * @return array Associative array ['US' => 'United States', 'IT' => 'Italy', ...] sorted alphabetically.
861 - */
862 -function accua_forms_get_countries( $display_locale = null ) {
863 - // ISO 3166-1 alpha-2 codes - complete list (249 countries/territories)
864 - $country_codes = array(
865 - 'AF', 'AX', 'AL', 'DZ', 'AS', 'AD', 'AO', 'AI', 'AQ', 'AG', 'AR', 'AM', 'AW', 'AU', 'AT', 'AZ',
866 - 'BS', 'BH', 'BD', 'BB', 'BY', 'BE', 'BZ', 'BJ', 'BM', 'BT', 'BO', 'BQ', 'BA', 'BW', 'BV', 'BR',
867 - 'IO', 'BN', 'BG', 'BF', 'BI', 'KH', 'CM', 'CA', 'CV', 'KY', 'CF', 'TD', 'CL', 'CN', 'CX', 'CC',
868 - 'CO', 'KM', 'CG', 'CD', 'CK', 'CR', 'CI', 'HR', 'CU', 'CW', 'CY', 'CZ', 'DK', 'DJ', 'DM', 'DO',
869 - 'EC', 'EG', 'SV', 'GQ', 'ER', 'EE', 'ET', 'FK', 'FO', 'FJ', 'FI', 'FR', 'GF', 'PF', 'TF', 'GA',
870 - 'GM', 'GE', 'DE', 'GH', 'GI', 'GR', 'GL', 'GD', 'GP', 'GU', 'GT', 'GG', 'GN', 'GW', 'GY', 'HT',
871 - 'HM', 'VA', 'HN', 'HK', 'HU', 'IS', 'IN', 'ID', 'IR', 'IQ', 'IE', 'IM', 'IL', 'IT', 'JM', 'JP',
872 - 'JE', 'JO', 'KZ', 'KE', 'KI', 'KP', 'KR', 'KW', 'KG', 'LA', 'LV', 'LB', 'LS', 'LR', 'LY', 'LI',
873 - 'LT', 'LU', 'MO', 'MK', 'MG', 'MW', 'MY', 'MV', 'ML', 'MT', 'MH', 'MQ', 'MR', 'MU', 'YT', 'MX',
874 - 'FM', 'MD', 'MC', 'MN', 'ME', 'MS', 'MA', 'MZ', 'MM', 'NA', 'NR', 'NP', 'NL', 'NC', 'NZ', 'NI',
875 - 'NE', 'NG', 'NU', 'NF', 'MP', 'NO', 'OM', 'PK', 'PW', 'PS', 'PA', 'PG', 'PY', 'PE', 'PH', 'PN',
876 - 'PL', 'PT', 'PR', 'QA', 'RE', 'RO', 'RU', 'RW', 'BL', 'SH', 'KN', 'LC', 'MF', 'PM', 'VC', 'WS',
877 - 'SM', 'ST', 'SA', 'SN', 'RS', 'SC', 'SL', 'SG', 'SX', 'SK', 'SI', 'SB', 'SO', 'ZA', 'GS', 'SS',
878 - 'ES', 'LK', 'SD', 'SR', 'SJ', 'SZ', 'SE', 'CH', 'SY', 'TW', 'TJ', 'TZ', 'TH', 'TL', 'TG', 'TK',
879 - 'TO', 'TT', 'TN', 'TR', 'TM', 'TC', 'TV', 'UG', 'UA', 'AE', 'GB', 'US', 'UM', 'UY', 'UZ', 'VU',
880 - 'VE', 'VN', 'VG', 'VI', 'WF', 'EH', 'YE', 'ZM', 'ZW',
881 - );
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 +}
882 682
883 - // Use WordPress locale if not specified
884 - if ( null === $display_locale ) {
885 - $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";
886 691 }
692 + return $output;
693 +}
887 694
888 - // Check if Intl extension is available
889 - if ( ! class_exists( 'Locale' ) ) {
890 - // Fallback: return codes as both key and value
891 - 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', '>=');
892 699 }
893 -
894 - $countries = array();
895 - foreach ( $country_codes as $code ) {
896 - // The trick: prepend '-' to convert region code to locale format
897 - $name = Locale::getDisplayRegion( '-' . $code, $display_locale );
898 - // If Intl returns the code itself (unknown region), use the code
899 - $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 + ));
900 709 }
901 -
902 - // Sort alphabetically by localized name
903 - asort( $countries, SORT_LOCALE_STRING );
904 -
905 - return $countries;
906 710 }
907 711
908 -/**
909 - * Get the translated label for a layout value.
910 - *
911 - * Returns the human-readable, translated label for a given layout value.
912 - * Used in layout dropdowns throughout the admin interface.
913 - *
914 - * @since 2.0.0-beta.29
915 - * @param string $layout Layout value: 'sidebyside', 'toplabel', or 'inlinelabel'.
916 - * @return string Translated layout label.
917 - */
918 -function accua_forms_get_layout_label( $layout ) {
919 - switch ( $layout ) {
920 - case 'toplabel':
921 - return __( 'Labels on top of the fields', 'contact-forms' );
922 - case 'inlinelabel':
923 - return __( 'Inline labels', 'contact-forms' );
924 - case 'sidebyside':
925 - default:
926 - return __( 'Labels on the left of the fields', 'contact-forms' );
927 - }
928 -}