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 | classes/Error/Standard.php +7 -92 2.2.41.9.2 View file →
@@ -1,6 +1,5 @@
1 1 <?php
2 -// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped, PluginCheck.CodeAnalysis.Heredoc -- PFBC Error class, HTML/JS output is controlled
3 2 class AccuaForm_Error_Standard extends PFBCError {
4 3 protected $errorfound;
5 4 protected $errorsfound;
6 5
@@ -15,44 +14,8 @@
15 14 errorHTML += '\\x3Cli\\x3E' + response.errors[e] + '\\x3C/li\\x3E';
16 15 }
17 16 errorHTML += '\\x3C/ul\\x3E\\x3C/div\\x3E';
18 17 jQuery("#$id").append(errorHTML);
19 -
20 -/* Apply ARIA attributes and inline errors for accessibility */
21 -if (response.elementErrors) {
22 - jQuery.each(response.elementErrors, function(fieldName, fieldErrors) {
23 - var field = jQuery('[name="' + fieldName + '"]', '#$id');
24 - if (field.length) {
25 - var parent = field.closest('.pfbc-element, .pfbc-fieldwrap');
26 - var errorId = field.attr('id') + '-error';
27 -
28 - /* Add ARIA attributes */
29 - field.attr('aria-invalid', 'true');
30 - field.attr('aria-describedby', errorId);
31 -
32 - /* Add error class to parent */
33 - parent.addClass('pfbc-element-has-error');
34 -
35 - /* Remove existing inline error if any */
36 - parent.find('.pfbc-inline-error').remove();
37 -
38 - /* Add inline error message */
39 - var inlineErrorHTML = '<div class="pfbc-inline-error" id="' + errorId + '" role="alert" aria-live="polite">';
40 - for (var i = 0; i < fieldErrors.length; i++) {
41 - inlineErrorHTML += '<div class="pfbc-error-message">' + fieldErrors[i] + '</div>';
42 - }
43 - inlineErrorHTML += '</div>';
44 -
45 - /* For file inputs with help text, insert error after help text */
46 - var helpText = field.siblings('.pfbc-help').last();
47 - if (field.is('[type="file"]') && helpText.length) {
48 - helpText.after(inlineErrorHTML);
49 - } else {
50 - field.after(inlineErrorHTML);
51 - }
52 - }
53 - });
54 -}
55 18 JS;
56 19
57 20 }
58 21
@@ -62,53 +25,14 @@
62 25 var errorHTML = '';
63 26 for(e = 0; e < errorSize; ++e) {
64 27 errorHTML += '\\x3Cli\\x3E' + response.errors[e] + '\\x3C/li\\x3E';
65 28 }
66 -
67 -/* Update summary area with server-side errors */
68 -if (typeof updateSummaryWithServerErrors === 'function') {
69 - updateSummaryWithServerErrors(response.errors, response.elementErrors);
70 -}
71 -
72 -/* Apply ARIA attributes and inline errors for accessibility */
73 -if (response.elementErrors) {
74 - jQuery.each(response.elementErrors, function(fieldName, fieldErrors) {
75 - var field = jQuery('[name="' + fieldName + '"]');
76 - if (field.length) {
77 - var parent = field.closest('.pfbc-element, .pfbc-fieldwrap');
78 - var errorId = field.attr('id') + '-error';
79 -
80 - /* Add ARIA attributes */
81 - field.attr('aria-invalid', 'true');
82 - field.attr('aria-describedby', errorId);
83 -
84 - /* Add error class to parent */
85 - parent.addClass('pfbc-element-has-error');
86 -
87 - /* Remove existing inline error if any */
88 - parent.find('.pfbc-inline-error').remove();
89 -
90 - /* Add inline error message */
91 - var inlineErrorHTML = '<div class=\"pfbc-inline-error\" id=\"' + errorId + '\" role=\"alert\" aria-live=\"polite\">';
92 - for (var i = 0; i < fieldErrors.length; i++) {
93 - inlineErrorHTML += '<div class=\"pfbc-error-message\">' + fieldErrors[i] + '</div>';
94 - }
95 - inlineErrorHTML += '</div>';
96 -
97 - /* For file inputs with help text, insert error after help text */
98 - var helpText = field.siblings('.pfbc-help').last();
99 - if (field.is('[type=\"file\"]') && helpText.length) {
100 - helpText.after(inlineErrorHTML);
101 - } else {
102 - field.after(inlineErrorHTML);
103 - }
104 - }
105 - });
106 -}
29 +show_error_messages(errorHTML);
107 30 JS;
108 31
109 32 }
110 - public function __construct(?array $properties = null) {
33 +
34 + public function __construct(array $properties = null) {
111 35 $this->errorfound = __('The following error was found:', 'contact-forms');
112 36 $this->errorsfound = __('The following @errorsize errors were found:', 'contact-forms');
113 37 $this->configure($properties);
114 38 }
@@ -145,24 +69,15 @@
145 69 }
146 70 }
147 71
148 72 public function getAjaxErrorResponse() {
149 - $flatErrors = $this->parse($this->form->getErrors());
150 - $elementErrors = $this->form->getErrors(); // Structured errors for ARIA attributes
151 - return array(
152 - 'errors' => $flatErrors,
153 - 'elementErrors' => $elementErrors
154 - );
73 + return $this->parse($this->form->getErrors());
155 74 }
156 75
157 76 public function renderAjaxErrorResponse() {
158 - $flatErrors = $this->parse($this->form->getErrors());
159 - $elementErrors = $this->form->getErrors(); // Keep structured errors for field-level ARIA
160 - if(!empty($flatErrors)) {
77 + $errors = $this->parse($this->form->getErrors());
78 + if(!empty($errors)) {
161 79 header("Content-type: application/json");
162 - print _accua_forms_json_encode(array(
163 - "errors" => $flatErrors,
164 - "elementErrors" => $elementErrors // Add field-specific errors for ARIA attributes
165 - ));
80 + print _accua_forms_json_encode(array("errors" => $errors));
166 81 }
167 82 }
168 83 }