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-form-api.php +16 -97 2.2.41.9.2 View file →
@@ -1,7 +1,5 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) exit;
3 -
4 2 function accua_form_Load($class) {
5 3 if (substr($class,0,10) === 'AccuaForm_') {
6 4 $class = substr($class, 10);
7 5 $file = ACCUA_FORMS_DIR . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . str_replace("_", DIRECTORY_SEPARATOR, $class) . ".php";
@@ -16,103 +14,30 @@
16 14 require_once('AccuaForm.php');
17 15
18 16 define('ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH', dirname( plugin_basename( __FILE__ ) ) . '/languages/');
19 17
20 -add_action('wp_enqueue_scripts', 'accua_form_enqueue_scripts_and_styles');
21 -add_action('admin_enqueue_scripts', 'accua_form_enqueue_scripts_and_styles');
22 -add_action('login_enqueue_scripts', 'accua_form_enqueue_scripts_and_styles');
23 -function accua_form_enqueue_scripts_and_styles(){
18 +add_action( 'wp_print_scripts', 'accua_form_init_scripts');
19 +function accua_form_init_scripts(){
20 + wp_enqueue_script('jquery');
21 + AccuaForm_Element_ColorPicker::maybe_load_colorPicker_scripts();
22 +}
23 +
24 +add_action('wp_enqueue_scripts', 'accua_form_enqueue_styles');
25 +add_action('admin_enqueue_scripts', 'accua_form_enqueue_styles');
26 +add_action('login_enqueue_scripts', 'accua_form_enqueue_styles');
27 +add_action('wp_print_styles', 'accua_form_enqueue_styles');
28 +function accua_form_enqueue_styles(){
24 29 static $first = TRUE;
25 30 if ($first) {
26 - wp_enqueue_script('jquery');
27 -
28 - // In admin context, use WordPress's wp-color-picker (has all dependencies available)
29 - if (is_admin()) {
30 - wp_enqueue_style('wp-color-picker');
31 - wp_enqueue_script('wp-color-picker');
32 - }
33 - // On frontend, we use HTML5 native color input (no JS dependencies needed)
34 - // This is WCAG 2.2 AA compliant, keyboard accessible, and works in all modern browsers
35 -
36 - wp_enqueue_style('accua-forms-api-base', plugins_url('assets/css/frontend.css', ACCUA_FORMS_FILE), array(), ACCUA_FORMS_CSS_VERSION);
37 -
38 - // Accessible file upload with drag & drop (WCAG 2.2 AA compliant)
39 - wp_enqueue_script(
40 - 'accua-file-upload',
41 - plugins_url('assets/js/frontend/file-upload.js', ACCUA_FORMS_FILE),
42 - array(), // No dependencies - vanilla JS
43 - ACCUA_FORMS_JS_VERSION,
44 - true // Load in footer
45 - );
46 -
47 - // Localized strings for file upload
48 - wp_localize_script('accua-file-upload', 'accuaFileUploadL10n', array(
49 - 'fileTooLarge' => __('File exceeds maximum allowed size', 'contact-forms'),
50 - 'invalidType' => __('File type not allowed', 'contact-forms'),
51 - 'fileAdded' => __('File added', 'contact-forms'),
52 - 'filesAdded' => __('files added', 'contact-forms'),
53 - 'fileRemoved' => __('File removed', 'contact-forms'),
54 - 'errors' => __('Errors', 'contact-forms'),
55 - 'removeFile' => __('Remove', 'contact-forms'),
56 - ));
57 -
58 - // libphonenumber-js for phone validation (min bundle, ~175KB)
59 - wp_enqueue_script(
60 - 'libphonenumber',
61 - plugins_url('assets/js/frontend/libphonenumber-min.js', ACCUA_FORMS_FILE),
62 - array(), // No dependencies
63 - '1.12.5', // libphonenumber-js version
64 - true // Load in footer
65 - );
66 -
67 - // Phone validation for telephone fields (WCAG 2.2 AA compliant)
68 - // Uses libphonenumber-js for proper international phone validation
69 - wp_enqueue_script(
70 - 'accua-phone-validation',
71 - plugins_url('assets/js/frontend/phone-validation.js', ACCUA_FORMS_FILE),
72 - array('jquery', 'libphonenumber'),
73 - ACCUA_FORMS_JS_VERSION,
74 - true // Load in footer
75 - );
76 -
77 - // Localized strings for phone validation
78 - wp_localize_script('accua-phone-validation', 'accuaPhoneL10n', array(
79 - 'phoneError' => __('Please enter a valid phone number (e.g. +39 333 1234567)', 'contact-forms'),
80 - ));
81 -
82 - // Post select - AJAX searchable dropdown for post-select fields (WCAG 2.2 AA compliant)
83 - wp_enqueue_script(
84 - 'accua-post-select',
85 - plugins_url('assets/js/frontend/post-select.js', ACCUA_FORMS_FILE),
86 - array(), // No dependencies - vanilla JS
87 - ACCUA_FORMS_JS_VERSION,
88 - true // Load in footer
89 - );
90 -
91 - // Localized strings for post select
92 - wp_localize_script('accua-post-select', 'accuaPostSelectI18n', array(
93 - 'select' => __('Select...', 'contact-forms'),
94 - 'search' => __('Search...', 'contact-forms'),
95 - 'loading' => __('Loading...', 'contact-forms'),
96 - 'noResults' => __('No results found', 'contact-forms'),
97 - 'loadMore' => __('Loading more...', 'contact-forms'),
98 - ));
99 -
100 - /**
101 - * Action fired after Contact Forms enqueues its scripts and styles.
102 - * External plugins can use this to enqueue their own field-specific assets.
103 - */
104 - do_action( 'accua_forms_enqueue_scripts' );
105 -
31 + AccuaForm_Element_ColorPicker::maybe_load_colorPicker_styles();
32 + wp_enqueue_style('accua-forms-api-base', plugins_url('accua-form-api.css', ACCUA_FORMS_FILE), array(), ACCUA_FORMS_CSS_VERSION);
106 33 $first = FALSE;
107 34 }
108 35 }
109 36
110 -// Priority 20 ensures SMTP plugins (WP Mail SMTP, etc.) initialize their phpmailer_init hooks first.
111 -// Many SMTP plugins register hooks inside plugins_loaded callbacks at default priority 10.
112 -// Without this delay, emails sent during form processing would bypass SMTP configuration.
113 -add_action('plugins_loaded', 'accua_form_init', 20);
37 +add_action('plugins_loaded', 'accua_form_init');
114 38 function accua_form_init(){
39 + load_plugin_textdomain( 'contact-forms', false, ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH);
115 40 if (!defined('DOING_CRON')) {
116 41 AccuaForm::isValid();
117 42 }
118 43 }
@@ -120,20 +45,15 @@
120 45 add_action('wp_ajax_accua_form_submit', 'accua_form_ajax_submit_handler');
121 46 add_action('wp_ajax_nopriv_accua_form_submit', 'accua_form_ajax_submit_handler');
122 47 function accua_form_ajax_submit_handler(){
123 48 header('Content-Type: text/html; charset='.get_option('blog_charset'));
124 - header('Cache-Control: no-transform');
125 49
126 50 echo '<html><head></head><body><pre id="accua-form-ajax-response">';
127 51
128 - $result = AccuaForm::ajaxSubmit();
129 -
130 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- JSON encoded data for JavaScript consumption
131 - print _accua_forms_json_encode($result);
52 + print _accua_forms_json_encode(AccuaForm::ajaxSubmit());
132 53
133 54 echo '</pre><div id="accua-form-ajax-response-loaded"></div>';
134 55
135 - // phpcs:disable PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- Heredoc for inline JavaScript
136 56 echo <<<EOJS
137 57 <script type="text/javascript">
138 58 <!--
139 59 try {
@@ -142,9 +62,8 @@
142 62 }
143 63 // -->
144 64 </script>
145 65 EOJS;
146 - // phpcs:enable PluginCheck.CodeAnalysis.Heredoc.NotAllowed
147 66
148 67 echo '</body></html>';
149 68 die('');
150 69 }