Version Description
https://contactform7.com/contact-form-7-561/
Download this release
Release Info
Developer | takayukister |
Plugin | Contact Form 7 |
Version | 5.6.1 |
Comparing to | |
See all releases |
Code changes from version 5.6 to 5.6.1
- includes/config-validator.php +225 -34
- includes/contact-form-functions.php +111 -10
- includes/contact-form.php +11 -10
- includes/form-tag.php +9 -5
- includes/functions.php +2 -2
- includes/js/index.js +1 -1
- includes/validation-functions.php +3 -3
- includes/validation.php +8 -4
- modules/really-simple-captcha.php +5 -3
- readme.txt +5 -1
- wp-contact-form-7.php +2 -2
includes/config-validator.php
CHANGED
@@ -1,8 +1,16 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class WPCF7_ConfigValidator {
|
4 |
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
const error = 100;
|
8 |
const error_maybe_empty = 101;
|
@@ -18,7 +26,12 @@ class WPCF7_ConfigValidator {
|
|
18 |
const error_unavailable_html_elements = 111;
|
19 |
const error_attachments_overweight = 112;
|
20 |
const error_dots_in_names = 113;
|
|
|
21 |
|
|
|
|
|
|
|
|
|
22 |
public static function get_doc_link( $error_code = '' ) {
|
23 |
$url = __( 'https://contactform7.com/configuration-errors/',
|
24 |
'contact-form-7'
|
@@ -33,6 +46,7 @@ class WPCF7_ConfigValidator {
|
|
33 |
return esc_url( $url );
|
34 |
}
|
35 |
|
|
|
36 |
private $contact_form;
|
37 |
private $errors = array();
|
38 |
|
@@ -40,14 +54,26 @@ class WPCF7_ConfigValidator {
|
|
40 |
$this->contact_form = $contact_form;
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
43 |
public function contact_form() {
|
44 |
return $this->contact_form;
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
47 |
public function is_valid() {
|
48 |
return ! $this->count_errors();
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
51 |
public function count_errors( $args = '' ) {
|
52 |
$args = wp_parse_args( $args, array(
|
53 |
'section' => '',
|
@@ -83,6 +109,10 @@ class WPCF7_ConfigValidator {
|
|
83 |
return $count;
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
86 |
public function collect_error_messages() {
|
87 |
$error_messages = array();
|
88 |
|
@@ -116,6 +146,10 @@ class WPCF7_ConfigValidator {
|
|
116 |
return $error_messages;
|
117 |
}
|
118 |
|
|
|
|
|
|
|
|
|
119 |
public function build_message( $message, $params = '' ) {
|
120 |
$params = wp_parse_args( $params, array() );
|
121 |
|
@@ -134,6 +168,11 @@ class WPCF7_ConfigValidator {
|
|
134 |
return $message;
|
135 |
}
|
136 |
|
|
|
|
|
|
|
|
|
|
|
137 |
public function get_default_message( $code ) {
|
138 |
switch ( $code ) {
|
139 |
case self::error_maybe_empty:
|
@@ -155,6 +194,15 @@ class WPCF7_ConfigValidator {
|
|
155 |
}
|
156 |
}
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
public function add_error( $section, $code, $args = '' ) {
|
159 |
$args = wp_parse_args( $args, array(
|
160 |
'message' => '',
|
@@ -170,6 +218,10 @@ class WPCF7_ConfigValidator {
|
|
170 |
return true;
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
173 |
public function remove_error( $section, $code ) {
|
174 |
if ( empty( $this->errors[$section] ) ) {
|
175 |
return;
|
@@ -187,6 +239,12 @@ class WPCF7_ConfigValidator {
|
|
187 |
}
|
188 |
}
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
public function validate() {
|
191 |
$this->errors = array();
|
192 |
|
@@ -201,6 +259,10 @@ class WPCF7_ConfigValidator {
|
|
201 |
return $this->is_valid();
|
202 |
}
|
203 |
|
|
|
|
|
|
|
|
|
204 |
public function save() {
|
205 |
if ( $this->contact_form->initial() ) {
|
206 |
return;
|
@@ -209,14 +271,20 @@ class WPCF7_ConfigValidator {
|
|
209 |
delete_post_meta( $this->contact_form->id(), '_config_errors' );
|
210 |
|
211 |
if ( $this->errors ) {
|
212 |
-
update_post_meta(
|
213 |
-
$this->errors
|
|
|
214 |
}
|
215 |
}
|
216 |
|
|
|
|
|
|
|
|
|
217 |
public function restore() {
|
218 |
$config_errors = get_post_meta(
|
219 |
-
$this->contact_form->id(), '_config_errors', true
|
|
|
220 |
|
221 |
foreach ( (array) $config_errors as $section => $errors ) {
|
222 |
if ( empty( $errors ) ) {
|
@@ -238,6 +306,11 @@ class WPCF7_ConfigValidator {
|
|
238 |
}
|
239 |
}
|
240 |
|
|
|
|
|
|
|
|
|
|
|
241 |
public function replace_mail_tags_with_minimum_input( $matches ) {
|
242 |
// allow [[foo]] syntax for escaping a tag
|
243 |
if ( $matches[1] == '[' && $matches[4] == ']' ) {
|
@@ -256,7 +329,8 @@ class WPCF7_ConfigValidator {
|
|
256 |
$example_blank = '';
|
257 |
|
258 |
$form_tags = $this->contact_form->scan_form_tags(
|
259 |
-
array( 'name' => $field_name )
|
|
|
260 |
|
261 |
if ( $form_tags ) {
|
262 |
$form_tag = new WPCF7_FormTag( $form_tags[0] );
|
@@ -324,6 +398,10 @@ class WPCF7_ConfigValidator {
|
|
324 |
return $tag;
|
325 |
}
|
326 |
|
|
|
|
|
|
|
|
|
327 |
public function validate_form() {
|
328 |
$section = 'form.body';
|
329 |
$form = $this->contact_form->prop( 'form' );
|
@@ -331,8 +409,15 @@ class WPCF7_ConfigValidator {
|
|
331 |
$this->detect_unavailable_names( $section, $form );
|
332 |
$this->detect_unavailable_html_elements( $section, $form );
|
333 |
$this->detect_dots_in_names( $section, $form );
|
|
|
334 |
}
|
335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
public function detect_multiple_controls_in_label( $section, $content ) {
|
337 |
$pattern = '%<label(?:[ \t\n]+.*?)?>(.+?)</label>%s';
|
338 |
|
@@ -345,9 +430,12 @@ class WPCF7_ConfigValidator {
|
|
345 |
|
346 |
foreach ( $tags as $tag ) {
|
347 |
$is_multiple_controls_container = wpcf7_form_tag_supports(
|
348 |
-
$tag->type, 'multiple-controls-container'
|
|
|
|
|
349 |
$is_zero_controls_container = wpcf7_form_tag_supports(
|
350 |
-
$tag->type, 'zero-controls-container'
|
|
|
351 |
|
352 |
if ( $is_multiple_controls_container ) {
|
353 |
$fields_count += count( $tag->values );
|
@@ -375,6 +463,12 @@ class WPCF7_ConfigValidator {
|
|
375 |
return false;
|
376 |
}
|
377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
public function detect_unavailable_names( $section, $content ) {
|
379 |
$public_query_vars = array( 'm', 'p', 'posts', 'w', 'cat',
|
380 |
'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence',
|
@@ -416,6 +510,12 @@ class WPCF7_ConfigValidator {
|
|
416 |
return false;
|
417 |
}
|
418 |
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
public function detect_unavailable_html_elements( $section, $content ) {
|
420 |
$pattern = '%(?:<form[\s\t>]|</form>)%i';
|
421 |
|
@@ -432,6 +532,12 @@ class WPCF7_ConfigValidator {
|
|
432 |
return false;
|
433 |
}
|
434 |
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
public function detect_dots_in_names( $section, $content ) {
|
436 |
$form_tags_manager = WPCF7_FormTagsManager::get_instance();
|
437 |
|
@@ -454,6 +560,38 @@ class WPCF7_ConfigValidator {
|
|
454 |
return false;
|
455 |
}
|
456 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
public function validate_mail( $template = 'mail' ) {
|
458 |
$components = (array) $this->contact_form->prop( $template );
|
459 |
|
@@ -461,8 +599,7 @@ class WPCF7_ConfigValidator {
|
|
461 |
return;
|
462 |
}
|
463 |
|
464 |
-
if ( 'mail'
|
465 |
-
and empty( $components['active'] ) ) {
|
466 |
return;
|
467 |
}
|
468 |
|
@@ -477,21 +614,30 @@ class WPCF7_ConfigValidator {
|
|
477 |
|
478 |
$callback = array( $this, 'replace_mail_tags_with_minimum_input' );
|
479 |
|
480 |
-
$subject =
|
481 |
-
|
482 |
-
array( 'callback' => $callback )
|
|
|
|
|
483 |
$subject = $subject->replace_tags();
|
484 |
$subject = wpcf7_strip_newline( $subject );
|
|
|
485 |
$this->detect_maybe_empty( sprintf( '%s.subject', $template ), $subject );
|
486 |
|
487 |
-
$sender =
|
488 |
-
|
489 |
-
array( 'callback' => $callback )
|
|
|
|
|
490 |
$sender = $sender->replace_tags();
|
491 |
$sender = wpcf7_strip_newline( $sender );
|
492 |
|
493 |
-
|
494 |
-
|
|
|
|
|
|
|
|
|
495 |
$this->add_error( sprintf( '%s.sender', $template ),
|
496 |
self::error_email_not_in_site_domain, array(
|
497 |
'link' => self::get_doc_link( 'email_not_in_site_domain' ),
|
@@ -499,18 +645,24 @@ class WPCF7_ConfigValidator {
|
|
499 |
);
|
500 |
}
|
501 |
|
502 |
-
$recipient =
|
503 |
-
|
504 |
-
array( 'callback' => $callback )
|
|
|
|
|
505 |
$recipient = $recipient->replace_tags();
|
506 |
$recipient = wpcf7_strip_newline( $recipient );
|
507 |
|
508 |
$this->detect_invalid_mailbox_syntax(
|
509 |
-
sprintf( '%s.recipient', $template ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
|
511 |
-
$additional_headers = $components['additional_headers'];
|
512 |
-
$additional_headers = new WPCF7_MailTaggedText( $additional_headers,
|
513 |
-
array( 'callback' => $callback ) );
|
514 |
$additional_headers = $additional_headers->replace_tags();
|
515 |
$additional_headers = explode( "\n", $additional_headers );
|
516 |
$mailbox_header_types = array( 'reply-to', 'cc', 'bcc' );
|
@@ -552,10 +704,13 @@ class WPCF7_ConfigValidator {
|
|
552 |
);
|
553 |
}
|
554 |
|
555 |
-
$body =
|
556 |
-
|
557 |
-
array( 'callback' => $callback )
|
|
|
|
|
558 |
$body = $body->replace_tags();
|
|
|
559 |
$this->detect_maybe_empty( sprintf( '%s.body', $template ), $body );
|
560 |
|
561 |
if ( '' !== $components['attachments'] ) {
|
@@ -588,8 +743,7 @@ class WPCF7_ConfigValidator {
|
|
588 |
foreach ( explode( "\n", $components['attachments'] ) as $line ) {
|
589 |
$line = trim( $line );
|
590 |
|
591 |
-
if ( '' === $line
|
592 |
-
or '[' == substr( $line, 0, 1 ) ) {
|
593 |
continue;
|
594 |
}
|
595 |
|
@@ -597,8 +751,7 @@ class WPCF7_ConfigValidator {
|
|
597 |
sprintf( '%s.attachments', $template ), $line
|
598 |
);
|
599 |
|
600 |
-
if ( ! $has_file_not_found
|
601 |
-
and ! $has_file_not_in_content_dir ) {
|
602 |
$has_file_not_in_content_dir = $this->detect_file_not_in_content_dir(
|
603 |
sprintf( '%s.attachments', $template ), $line
|
604 |
);
|
@@ -624,6 +777,12 @@ class WPCF7_ConfigValidator {
|
|
624 |
}
|
625 |
}
|
626 |
|
|
|
|
|
|
|
|
|
|
|
|
|
627 |
public function detect_invalid_mailbox_syntax( $section, $content, $args = '' ) {
|
628 |
$args = wp_parse_args( $args, array(
|
629 |
'link' => self::get_doc_link( 'invalid_mailbox_syntax' ),
|
@@ -633,12 +792,19 @@ class WPCF7_ConfigValidator {
|
|
633 |
|
634 |
if ( ! wpcf7_is_mailbox_list( $content ) ) {
|
635 |
return $this->add_error( $section,
|
636 |
-
self::error_invalid_mailbox_syntax, $args
|
|
|
637 |
}
|
638 |
|
639 |
return false;
|
640 |
}
|
641 |
|
|
|
|
|
|
|
|
|
|
|
|
|
642 |
public function detect_maybe_empty( $section, $content ) {
|
643 |
if ( '' === $content ) {
|
644 |
return $this->add_error( $section,
|
@@ -651,11 +817,16 @@ class WPCF7_ConfigValidator {
|
|
651 |
return false;
|
652 |
}
|
653 |
|
|
|
|
|
|
|
|
|
|
|
|
|
654 |
public function detect_file_not_found( $section, $content ) {
|
655 |
$path = path_join( WP_CONTENT_DIR, $content );
|
656 |
|
657 |
-
if ( ! is_readable( $path )
|
658 |
-
or ! is_file( $path ) ) {
|
659 |
return $this->add_error( $section,
|
660 |
self::error_file_not_found,
|
661 |
array(
|
@@ -670,6 +841,12 @@ class WPCF7_ConfigValidator {
|
|
670 |
return false;
|
671 |
}
|
672 |
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
public function detect_file_not_in_content_dir( $section, $content ) {
|
674 |
$path = path_join( WP_CONTENT_DIR, $content );
|
675 |
|
@@ -687,6 +864,10 @@ class WPCF7_ConfigValidator {
|
|
687 |
return false;
|
688 |
}
|
689 |
|
|
|
|
|
|
|
|
|
690 |
public function validate_messages() {
|
691 |
$messages = (array) $this->contact_form->prop( 'messages' );
|
692 |
|
@@ -705,6 +886,12 @@ class WPCF7_ConfigValidator {
|
|
705 |
}
|
706 |
}
|
707 |
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
public function detect_html_in_message( $section, $content ) {
|
709 |
$stripped = wp_strip_all_tags( $content );
|
710 |
|
@@ -720,6 +907,10 @@ class WPCF7_ConfigValidator {
|
|
720 |
return false;
|
721 |
}
|
722 |
|
|
|
|
|
|
|
|
|
723 |
public function validate_additional_settings() {
|
724 |
$deprecated_settings_used =
|
725 |
$this->contact_form->additional_setting( 'on_sent_ok' ) ||
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Configuration validator.
|
5 |
+
*
|
6 |
+
* @link https://contactform7.com/configuration-errors/
|
7 |
+
*/
|
8 |
class WPCF7_ConfigValidator {
|
9 |
|
10 |
+
/**
|
11 |
+
* The plugin version in which important updates happened last time.
|
12 |
+
*/
|
13 |
+
const last_important_update = '5.6.1';
|
14 |
|
15 |
const error = 100;
|
16 |
const error_maybe_empty = 101;
|
26 |
const error_unavailable_html_elements = 111;
|
27 |
const error_attachments_overweight = 112;
|
28 |
const error_dots_in_names = 113;
|
29 |
+
const error_colons_in_names = 114;
|
30 |
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Returns a URL linking to the documentation page for the error type.
|
34 |
+
*/
|
35 |
public static function get_doc_link( $error_code = '' ) {
|
36 |
$url = __( 'https://contactform7.com/configuration-errors/',
|
37 |
'contact-form-7'
|
46 |
return esc_url( $url );
|
47 |
}
|
48 |
|
49 |
+
|
50 |
private $contact_form;
|
51 |
private $errors = array();
|
52 |
|
54 |
$this->contact_form = $contact_form;
|
55 |
}
|
56 |
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Returns the contact form object that is tied to this validator.
|
60 |
+
*/
|
61 |
public function contact_form() {
|
62 |
return $this->contact_form;
|
63 |
}
|
64 |
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Returns true if no error has been detected.
|
68 |
+
*/
|
69 |
public function is_valid() {
|
70 |
return ! $this->count_errors();
|
71 |
}
|
72 |
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Counts detected errors.
|
76 |
+
*/
|
77 |
public function count_errors( $args = '' ) {
|
78 |
$args = wp_parse_args( $args, array(
|
79 |
'section' => '',
|
109 |
return $count;
|
110 |
}
|
111 |
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Collects messages for detected errors.
|
115 |
+
*/
|
116 |
public function collect_error_messages() {
|
117 |
$error_messages = array();
|
118 |
|
146 |
return $error_messages;
|
147 |
}
|
148 |
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Builds an error message by replacing placeholders.
|
152 |
+
*/
|
153 |
public function build_message( $message, $params = '' ) {
|
154 |
$params = wp_parse_args( $params, array() );
|
155 |
|
168 |
return $message;
|
169 |
}
|
170 |
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Returns a default message that is used when the message for the error
|
174 |
+
* is not specified.
|
175 |
+
*/
|
176 |
public function get_default_message( $code ) {
|
177 |
switch ( $code ) {
|
178 |
case self::error_maybe_empty:
|
194 |
}
|
195 |
}
|
196 |
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Adds a validation error.
|
200 |
+
*
|
201 |
+
* @param string $section The section where the error detected.
|
202 |
+
* @param int $code The unique code of the error.
|
203 |
+
* This must be one of the class constants.
|
204 |
+
* @param string|array $args Optional options for the error.
|
205 |
+
*/
|
206 |
public function add_error( $section, $code, $args = '' ) {
|
207 |
$args = wp_parse_args( $args, array(
|
208 |
'message' => '',
|
218 |
return true;
|
219 |
}
|
220 |
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Removes an error.
|
224 |
+
*/
|
225 |
public function remove_error( $section, $code ) {
|
226 |
if ( empty( $this->errors[$section] ) ) {
|
227 |
return;
|
239 |
}
|
240 |
}
|
241 |
|
242 |
+
|
243 |
+
/**
|
244 |
+
* The main validation runner.
|
245 |
+
*
|
246 |
+
* @return bool True if there is no error detected.
|
247 |
+
*/
|
248 |
public function validate() {
|
249 |
$this->errors = array();
|
250 |
|
259 |
return $this->is_valid();
|
260 |
}
|
261 |
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Saves detected errors as a post meta data.
|
265 |
+
*/
|
266 |
public function save() {
|
267 |
if ( $this->contact_form->initial() ) {
|
268 |
return;
|
271 |
delete_post_meta( $this->contact_form->id(), '_config_errors' );
|
272 |
|
273 |
if ( $this->errors ) {
|
274 |
+
update_post_meta(
|
275 |
+
$this->contact_form->id(), '_config_errors', $this->errors
|
276 |
+
);
|
277 |
}
|
278 |
}
|
279 |
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Restore errors from the database.
|
283 |
+
*/
|
284 |
public function restore() {
|
285 |
$config_errors = get_post_meta(
|
286 |
+
$this->contact_form->id(), '_config_errors', true
|
287 |
+
);
|
288 |
|
289 |
foreach ( (array) $config_errors as $section => $errors ) {
|
290 |
if ( empty( $errors ) ) {
|
306 |
}
|
307 |
}
|
308 |
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Callback function for WPCF7_MailTaggedText. Replaces mail-tags with
|
312 |
+
* the most conservative inputs.
|
313 |
+
*/
|
314 |
public function replace_mail_tags_with_minimum_input( $matches ) {
|
315 |
// allow [[foo]] syntax for escaping a tag
|
316 |
if ( $matches[1] == '[' && $matches[4] == ']' ) {
|
329 |
$example_blank = '';
|
330 |
|
331 |
$form_tags = $this->contact_form->scan_form_tags(
|
332 |
+
array( 'name' => $field_name )
|
333 |
+
);
|
334 |
|
335 |
if ( $form_tags ) {
|
336 |
$form_tag = new WPCF7_FormTag( $form_tags[0] );
|
398 |
return $tag;
|
399 |
}
|
400 |
|
401 |
+
|
402 |
+
/**
|
403 |
+
* Runs error detection for the form section.
|
404 |
+
*/
|
405 |
public function validate_form() {
|
406 |
$section = 'form.body';
|
407 |
$form = $this->contact_form->prop( 'form' );
|
409 |
$this->detect_unavailable_names( $section, $form );
|
410 |
$this->detect_unavailable_html_elements( $section, $form );
|
411 |
$this->detect_dots_in_names( $section, $form );
|
412 |
+
$this->detect_colons_in_names( $section, $form );
|
413 |
}
|
414 |
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Detects errors of multiple form controls in a single label.
|
418 |
+
*
|
419 |
+
* @link https://contactform7.com/configuration-errors/multiple-controls-in-label/
|
420 |
+
*/
|
421 |
public function detect_multiple_controls_in_label( $section, $content ) {
|
422 |
$pattern = '%<label(?:[ \t\n]+.*?)?>(.+?)</label>%s';
|
423 |
|
430 |
|
431 |
foreach ( $tags as $tag ) {
|
432 |
$is_multiple_controls_container = wpcf7_form_tag_supports(
|
433 |
+
$tag->type, 'multiple-controls-container'
|
434 |
+
);
|
435 |
+
|
436 |
$is_zero_controls_container = wpcf7_form_tag_supports(
|
437 |
+
$tag->type, 'zero-controls-container'
|
438 |
+
);
|
439 |
|
440 |
if ( $is_multiple_controls_container ) {
|
441 |
$fields_count += count( $tag->values );
|
463 |
return false;
|
464 |
}
|
465 |
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Detects errors of unavailable form-tag names.
|
469 |
+
*
|
470 |
+
* @link https://contactform7.com/configuration-errors/unavailable-names/
|
471 |
+
*/
|
472 |
public function detect_unavailable_names( $section, $content ) {
|
473 |
$public_query_vars = array( 'm', 'p', 'posts', 'w', 'cat',
|
474 |
'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence',
|
510 |
return false;
|
511 |
}
|
512 |
|
513 |
+
|
514 |
+
/**
|
515 |
+
* Detects errors of unavailable HTML elements.
|
516 |
+
*
|
517 |
+
* @link https://contactform7.com/configuration-errors/unavailable-html-elements/
|
518 |
+
*/
|
519 |
public function detect_unavailable_html_elements( $section, $content ) {
|
520 |
$pattern = '%(?:<form[\s\t>]|</form>)%i';
|
521 |
|
532 |
return false;
|
533 |
}
|
534 |
|
535 |
+
|
536 |
+
/**
|
537 |
+
* Detects errors of dots in form-tag names.
|
538 |
+
*
|
539 |
+
* @link https://contactform7.com/configuration-errors/dots-in-names/
|
540 |
+
*/
|
541 |
public function detect_dots_in_names( $section, $content ) {
|
542 |
$form_tags_manager = WPCF7_FormTagsManager::get_instance();
|
543 |
|
560 |
return false;
|
561 |
}
|
562 |
|
563 |
+
|
564 |
+
/**
|
565 |
+
* Detects errors of colons in form-tag names.
|
566 |
+
*
|
567 |
+
* @link https://contactform7.com/configuration-errors/colons-in-names/
|
568 |
+
*/
|
569 |
+
public function detect_colons_in_names( $section, $content ) {
|
570 |
+
$form_tags_manager = WPCF7_FormTagsManager::get_instance();
|
571 |
+
|
572 |
+
$tags = $form_tags_manager->filter( $content, array(
|
573 |
+
'feature' => 'name-attr',
|
574 |
+
) );
|
575 |
+
|
576 |
+
foreach ( $tags as $tag ) {
|
577 |
+
if ( false !== strpos( $tag->raw_name, ':' ) ) {
|
578 |
+
return $this->add_error( $section,
|
579 |
+
self::error_colons_in_names,
|
580 |
+
array(
|
581 |
+
'message' => __( "Colons are used in form-tag names.", 'contact-form-7' ),
|
582 |
+
'link' => self::get_doc_link( 'colons_in_names' ),
|
583 |
+
)
|
584 |
+
);
|
585 |
+
}
|
586 |
+
}
|
587 |
+
|
588 |
+
return false;
|
589 |
+
}
|
590 |
+
|
591 |
+
|
592 |
+
/**
|
593 |
+
* Runs error detection for the mail sections.
|
594 |
+
*/
|
595 |
public function validate_mail( $template = 'mail' ) {
|
596 |
$components = (array) $this->contact_form->prop( $template );
|
597 |
|
599 |
return;
|
600 |
}
|
601 |
|
602 |
+
if ( 'mail' !== $template and empty( $components['active'] ) ) {
|
|
|
603 |
return;
|
604 |
}
|
605 |
|
614 |
|
615 |
$callback = array( $this, 'replace_mail_tags_with_minimum_input' );
|
616 |
|
617 |
+
$subject = new WPCF7_MailTaggedText(
|
618 |
+
$components['subject'],
|
619 |
+
array( 'callback' => $callback )
|
620 |
+
);
|
621 |
+
|
622 |
$subject = $subject->replace_tags();
|
623 |
$subject = wpcf7_strip_newline( $subject );
|
624 |
+
|
625 |
$this->detect_maybe_empty( sprintf( '%s.subject', $template ), $subject );
|
626 |
|
627 |
+
$sender = new WPCF7_MailTaggedText(
|
628 |
+
$components['sender'],
|
629 |
+
array( 'callback' => $callback )
|
630 |
+
);
|
631 |
+
|
632 |
$sender = $sender->replace_tags();
|
633 |
$sender = wpcf7_strip_newline( $sender );
|
634 |
|
635 |
+
$invalid_mailbox = $this->detect_invalid_mailbox_syntax(
|
636 |
+
sprintf( '%s.sender', $template ),
|
637 |
+
$sender
|
638 |
+
);
|
639 |
+
|
640 |
+
if ( ! $invalid_mailbox and ! wpcf7_is_email_in_site_domain( $sender ) ) {
|
641 |
$this->add_error( sprintf( '%s.sender', $template ),
|
642 |
self::error_email_not_in_site_domain, array(
|
643 |
'link' => self::get_doc_link( 'email_not_in_site_domain' ),
|
645 |
);
|
646 |
}
|
647 |
|
648 |
+
$recipient = new WPCF7_MailTaggedText(
|
649 |
+
$components['recipient'],
|
650 |
+
array( 'callback' => $callback )
|
651 |
+
);
|
652 |
+
|
653 |
$recipient = $recipient->replace_tags();
|
654 |
$recipient = wpcf7_strip_newline( $recipient );
|
655 |
|
656 |
$this->detect_invalid_mailbox_syntax(
|
657 |
+
sprintf( '%s.recipient', $template ),
|
658 |
+
$recipient
|
659 |
+
);
|
660 |
+
|
661 |
+
$additional_headers = new WPCF7_MailTaggedText(
|
662 |
+
$components['additional_headers'],
|
663 |
+
array( 'callback' => $callback )
|
664 |
+
);
|
665 |
|
|
|
|
|
|
|
666 |
$additional_headers = $additional_headers->replace_tags();
|
667 |
$additional_headers = explode( "\n", $additional_headers );
|
668 |
$mailbox_header_types = array( 'reply-to', 'cc', 'bcc' );
|
704 |
);
|
705 |
}
|
706 |
|
707 |
+
$body = new WPCF7_MailTaggedText(
|
708 |
+
$components['body'],
|
709 |
+
array( 'callback' => $callback )
|
710 |
+
);
|
711 |
+
|
712 |
$body = $body->replace_tags();
|
713 |
+
|
714 |
$this->detect_maybe_empty( sprintf( '%s.body', $template ), $body );
|
715 |
|
716 |
if ( '' !== $components['attachments'] ) {
|
743 |
foreach ( explode( "\n", $components['attachments'] ) as $line ) {
|
744 |
$line = trim( $line );
|
745 |
|
746 |
+
if ( '' === $line or '[' == substr( $line, 0, 1 ) ) {
|
|
|
747 |
continue;
|
748 |
}
|
749 |
|
751 |
sprintf( '%s.attachments', $template ), $line
|
752 |
);
|
753 |
|
754 |
+
if ( ! $has_file_not_found and ! $has_file_not_in_content_dir ) {
|
|
|
755 |
$has_file_not_in_content_dir = $this->detect_file_not_in_content_dir(
|
756 |
sprintf( '%s.attachments', $template ), $line
|
757 |
);
|
777 |
}
|
778 |
}
|
779 |
|
780 |
+
|
781 |
+
/**
|
782 |
+
* Detects errors of invalid mailbox syntax.
|
783 |
+
*
|
784 |
+
* @link https://contactform7.com/configuration-errors/invalid-mailbox-syntax/
|
785 |
+
*/
|
786 |
public function detect_invalid_mailbox_syntax( $section, $content, $args = '' ) {
|
787 |
$args = wp_parse_args( $args, array(
|
788 |
'link' => self::get_doc_link( 'invalid_mailbox_syntax' ),
|
792 |
|
793 |
if ( ! wpcf7_is_mailbox_list( $content ) ) {
|
794 |
return $this->add_error( $section,
|
795 |
+
self::error_invalid_mailbox_syntax, $args
|
796 |
+
);
|
797 |
}
|
798 |
|
799 |
return false;
|
800 |
}
|
801 |
|
802 |
+
|
803 |
+
/**
|
804 |
+
* Detects errors of empty message fields.
|
805 |
+
*
|
806 |
+
* @link https://contactform7.com/configuration-errors/maybe-empty/
|
807 |
+
*/
|
808 |
public function detect_maybe_empty( $section, $content ) {
|
809 |
if ( '' === $content ) {
|
810 |
return $this->add_error( $section,
|
817 |
return false;
|
818 |
}
|
819 |
|
820 |
+
|
821 |
+
/**
|
822 |
+
* Detects errors of nonexistent attachment files.
|
823 |
+
*
|
824 |
+
* @link https://contactform7.com/configuration-errors/file-not-found/
|
825 |
+
*/
|
826 |
public function detect_file_not_found( $section, $content ) {
|
827 |
$path = path_join( WP_CONTENT_DIR, $content );
|
828 |
|
829 |
+
if ( ! is_readable( $path ) or ! is_file( $path ) ) {
|
|
|
830 |
return $this->add_error( $section,
|
831 |
self::error_file_not_found,
|
832 |
array(
|
841 |
return false;
|
842 |
}
|
843 |
|
844 |
+
|
845 |
+
/**
|
846 |
+
* Detects errors of attachment files out of the content directory.
|
847 |
+
*
|
848 |
+
* @link https://contactform7.com/configuration-errors/file-not-in-content-dir/
|
849 |
+
*/
|
850 |
public function detect_file_not_in_content_dir( $section, $content ) {
|
851 |
$path = path_join( WP_CONTENT_DIR, $content );
|
852 |
|
864 |
return false;
|
865 |
}
|
866 |
|
867 |
+
|
868 |
+
/**
|
869 |
+
* Runs error detection for the messages section.
|
870 |
+
*/
|
871 |
public function validate_messages() {
|
872 |
$messages = (array) $this->contact_form->prop( 'messages' );
|
873 |
|
886 |
}
|
887 |
}
|
888 |
|
889 |
+
|
890 |
+
/**
|
891 |
+
* Detects errors of HTML uses in a message.
|
892 |
+
*
|
893 |
+
* @link https://contactform7.com/configuration-errors/html-in-message/
|
894 |
+
*/
|
895 |
public function detect_html_in_message( $section, $content ) {
|
896 |
$stripped = wp_strip_all_tags( $content );
|
897 |
|
907 |
return false;
|
908 |
}
|
909 |
|
910 |
+
|
911 |
+
/**
|
912 |
+
* Runs error detection for the additional settings section.
|
913 |
+
*/
|
914 |
public function validate_additional_settings() {
|
915 |
$deprecated_settings_used =
|
916 |
$this->contact_form->additional_setting( 'on_sent_ok' ) ||
|
includes/contact-form-functions.php
CHANGED
@@ -1,9 +1,26 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
}
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
function wpcf7_get_contact_form_by_old_id( $old_id ) {
|
8 |
global $wpdb;
|
9 |
|
@@ -15,6 +32,13 @@ function wpcf7_get_contact_form_by_old_id( $old_id ) {
|
|
15 |
}
|
16 |
}
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
function wpcf7_get_contact_form_by_title( $title ) {
|
19 |
$page = get_page_by_title( $title, OBJECT, WPCF7_ContactForm::post_type );
|
20 |
|
@@ -25,12 +49,22 @@ function wpcf7_get_contact_form_by_title( $title ) {
|
|
25 |
return null;
|
26 |
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
function wpcf7_get_current_contact_form() {
|
29 |
if ( $current = WPCF7_ContactForm::get_current() ) {
|
30 |
return $current;
|
31 |
}
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
34 |
function wpcf7_is_posted() {
|
35 |
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
36 |
return false;
|
@@ -39,6 +73,14 @@ function wpcf7_is_posted() {
|
|
39 |
return $contact_form->is_posted();
|
40 |
}
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
function wpcf7_get_hangover( $name, $default_value = null ) {
|
43 |
if ( ! wpcf7_is_posted() ) {
|
44 |
return $default_value;
|
@@ -54,6 +96,13 @@ function wpcf7_get_hangover( $name, $default_value = null ) {
|
|
54 |
return isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : $default_value;
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
function wpcf7_get_validation_error( $name ) {
|
58 |
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
59 |
return '';
|
@@ -62,18 +111,38 @@ function wpcf7_get_validation_error( $name ) {
|
|
62 |
return $contact_form->validation_error( $name );
|
63 |
}
|
64 |
|
65 |
-
function wpcf7_get_validation_error_reference( $name ) {
|
66 |
-
$contact_form = wpcf7_get_current_contact_form();
|
67 |
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
'%1$s-ve-%2$s',
|
71 |
-
$
|
72 |
$name
|
73 |
-
)
|
74 |
-
|
75 |
}
|
76 |
|
|
|
|
|
|
|
|
|
77 |
function wpcf7_get_message( $status ) {
|
78 |
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
79 |
return '';
|
@@ -82,6 +151,14 @@ function wpcf7_get_message( $status ) {
|
|
82 |
return $contact_form->message( $status );
|
83 |
}
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
function wpcf7_form_controls_class( $type, $default_classes = '' ) {
|
86 |
$type = trim( $type );
|
87 |
$default_classes = array_filter( explode( ' ', $default_classes ) );
|
@@ -102,6 +179,10 @@ function wpcf7_form_controls_class( $type, $default_classes = '' ) {
|
|
102 |
return implode( ' ', $classes );
|
103 |
}
|
104 |
|
|
|
|
|
|
|
|
|
105 |
function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
|
106 |
if ( is_feed() ) {
|
107 |
return '[contact-form-7]';
|
@@ -146,6 +227,10 @@ function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
|
|
146 |
return $contact_form->form_html( $atts );
|
147 |
}
|
148 |
|
|
|
|
|
|
|
|
|
149 |
function wpcf7_save_contact_form( $args = '', $context = 'save' ) {
|
150 |
$args = wp_parse_args( $args, array(
|
151 |
'id' => -1,
|
@@ -216,6 +301,10 @@ function wpcf7_save_contact_form( $args = '', $context = 'save' ) {
|
|
216 |
return $contact_form;
|
217 |
}
|
218 |
|
|
|
|
|
|
|
|
|
219 |
function wpcf7_sanitize_form( $input, $default_template = '' ) {
|
220 |
if ( null === $input ) {
|
221 |
return $default_template;
|
@@ -230,6 +319,10 @@ function wpcf7_sanitize_form( $input, $default_template = '' ) {
|
|
230 |
return $output;
|
231 |
}
|
232 |
|
|
|
|
|
|
|
|
|
233 |
function wpcf7_sanitize_mail( $input, $defaults = array() ) {
|
234 |
$input = wp_parse_args( $input, array(
|
235 |
'active' => false,
|
@@ -277,6 +370,10 @@ function wpcf7_sanitize_mail( $input, $defaults = array() ) {
|
|
277 |
return $output;
|
278 |
}
|
279 |
|
|
|
|
|
|
|
|
|
280 |
function wpcf7_sanitize_messages( $input, $defaults = array() ) {
|
281 |
$output = array();
|
282 |
|
@@ -291,6 +388,10 @@ function wpcf7_sanitize_messages( $input, $defaults = array() ) {
|
|
291 |
return $output;
|
292 |
}
|
293 |
|
|
|
|
|
|
|
|
|
294 |
function wpcf7_sanitize_additional_settings( $input, $default_template = '' ) {
|
295 |
if ( null === $input ) {
|
296 |
return $default_template;
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Contact form helper functions
|
4 |
+
*/
|
5 |
+
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Wrapper function of WPCF7_ContactForm::get_instance().
|
9 |
+
*
|
10 |
+
* @param int|WP_Post $post Post ID or post object.
|
11 |
+
* @return WPCF7_ContactForm Contact form object.
|
12 |
+
*/
|
13 |
+
function wpcf7_contact_form( $post ) {
|
14 |
+
return WPCF7_ContactForm::get_instance( $post );
|
15 |
}
|
16 |
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Searches for a contact form by an old unit ID.
|
20 |
+
*
|
21 |
+
* @param int $old_id Old unit ID.
|
22 |
+
* @return WPCF7_ContactForm Contact form object.
|
23 |
+
*/
|
24 |
function wpcf7_get_contact_form_by_old_id( $old_id ) {
|
25 |
global $wpdb;
|
26 |
|
32 |
}
|
33 |
}
|
34 |
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Searches for a contact form by title.
|
38 |
+
*
|
39 |
+
* @param string $title Title of contact form.
|
40 |
+
* @return WPCF7_ContactForm|null Contact form object if found, null otherwise.
|
41 |
+
*/
|
42 |
function wpcf7_get_contact_form_by_title( $title ) {
|
43 |
$page = get_page_by_title( $title, OBJECT, WPCF7_ContactForm::post_type );
|
44 |
|
49 |
return null;
|
50 |
}
|
51 |
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Wrapper function of WPCF7_ContactForm::get_current().
|
55 |
+
*
|
56 |
+
* @return WPCF7_ContactForm Contact form object.
|
57 |
+
*/
|
58 |
function wpcf7_get_current_contact_form() {
|
59 |
if ( $current = WPCF7_ContactForm::get_current() ) {
|
60 |
return $current;
|
61 |
}
|
62 |
}
|
63 |
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Returns true if it is in the state that a non-Ajax submission is accepted.
|
67 |
+
*/
|
68 |
function wpcf7_is_posted() {
|
69 |
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
70 |
return false;
|
73 |
return $contact_form->is_posted();
|
74 |
}
|
75 |
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Retrieves the user input value through a non-Ajax submission.
|
79 |
+
*
|
80 |
+
* @param string $name Name of form control.
|
81 |
+
* @param string $default_value Optional default value.
|
82 |
+
* @return string The user input value through the form-control.
|
83 |
+
*/
|
84 |
function wpcf7_get_hangover( $name, $default_value = null ) {
|
85 |
if ( ! wpcf7_is_posted() ) {
|
86 |
return $default_value;
|
96 |
return isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : $default_value;
|
97 |
}
|
98 |
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Retrieves an HTML snippet of validation error on the given form control.
|
102 |
+
*
|
103 |
+
* @param string $name Name of form control.
|
104 |
+
* @return string Validation error message in a form of HTML snippet.
|
105 |
+
*/
|
106 |
function wpcf7_get_validation_error( $name ) {
|
107 |
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
108 |
return '';
|
111 |
return $contact_form->validation_error( $name );
|
112 |
}
|
113 |
|
|
|
|
|
114 |
|
115 |
+
/**
|
116 |
+
* Returns a reference key to a validation error message.
|
117 |
+
*
|
118 |
+
* @param string $name Name of form control.
|
119 |
+
* @param string $unit_tag Optional. Unit tag of the contact form.
|
120 |
+
* @return string Reference key code.
|
121 |
+
*/
|
122 |
+
function wpcf7_get_validation_error_reference( $name, $unit_tag = '' ) {
|
123 |
+
if ( '' === $unit_tag ) {
|
124 |
+
$contact_form = wpcf7_get_current_contact_form();
|
125 |
+
|
126 |
+
if ( $contact_form and $contact_form->validation_error( $name ) ) {
|
127 |
+
$unit_tag = $contact_form->unit_tag();
|
128 |
+
} else {
|
129 |
+
return null;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
return preg_replace( '/[^0-9a-z_-]+/i', '',
|
134 |
+
sprintf(
|
135 |
'%1$s-ve-%2$s',
|
136 |
+
$unit_tag,
|
137 |
$name
|
138 |
+
)
|
139 |
+
);
|
140 |
}
|
141 |
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Retrieves a message for the given status.
|
145 |
+
*/
|
146 |
function wpcf7_get_message( $status ) {
|
147 |
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
148 |
return '';
|
151 |
return $contact_form->message( $status );
|
152 |
}
|
153 |
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Returns a class names list for a form-tag of the specified type.
|
157 |
+
*
|
158 |
+
* @param string $type Form-tag type.
|
159 |
+
* @param string $default_classes Optional default classes.
|
160 |
+
* @return string Whitespace-separated list of class names.
|
161 |
+
*/
|
162 |
function wpcf7_form_controls_class( $type, $default_classes = '' ) {
|
163 |
$type = trim( $type );
|
164 |
$default_classes = array_filter( explode( ' ', $default_classes ) );
|
179 |
return implode( ' ', $classes );
|
180 |
}
|
181 |
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Callback function for the contact-form-7 shortcode.
|
185 |
+
*/
|
186 |
function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
|
187 |
if ( is_feed() ) {
|
188 |
return '[contact-form-7]';
|
227 |
return $contact_form->form_html( $atts );
|
228 |
}
|
229 |
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Saves the contact form data.
|
233 |
+
*/
|
234 |
function wpcf7_save_contact_form( $args = '', $context = 'save' ) {
|
235 |
$args = wp_parse_args( $args, array(
|
236 |
'id' => -1,
|
301 |
return $contact_form;
|
302 |
}
|
303 |
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Sanitizes the form property data.
|
307 |
+
*/
|
308 |
function wpcf7_sanitize_form( $input, $default_template = '' ) {
|
309 |
if ( null === $input ) {
|
310 |
return $default_template;
|
319 |
return $output;
|
320 |
}
|
321 |
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Sanitizes the mail property data.
|
325 |
+
*/
|
326 |
function wpcf7_sanitize_mail( $input, $defaults = array() ) {
|
327 |
$input = wp_parse_args( $input, array(
|
328 |
'active' => false,
|
370 |
return $output;
|
371 |
}
|
372 |
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Sanitizes the messages property data.
|
376 |
+
*/
|
377 |
function wpcf7_sanitize_messages( $input, $defaults = array() ) {
|
378 |
$output = array();
|
379 |
|
388 |
return $output;
|
389 |
}
|
390 |
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Sanitizes the additional settings property data.
|
394 |
+
*/
|
395 |
function wpcf7_sanitize_additional_settings( $input, $default_template = '' ) {
|
396 |
if ( null === $input ) {
|
397 |
return $default_template;
|
includes/contact-form.php
CHANGED
@@ -775,19 +775,20 @@ class WPCF7_ContactForm {
|
|
775 |
);
|
776 |
}
|
777 |
|
778 |
-
$validation_error_id =
|
779 |
-
|
780 |
-
$this->unit_tag()
|
781 |
-
$name
|
782 |
);
|
783 |
|
784 |
-
$
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
|
|
789 |
|
790 |
-
|
|
|
791 |
}
|
792 |
}
|
793 |
}
|
775 |
);
|
776 |
}
|
777 |
|
778 |
+
$validation_error_id = wpcf7_get_validation_error_reference(
|
779 |
+
$name,
|
780 |
+
$this->unit_tag()
|
|
|
781 |
);
|
782 |
|
783 |
+
if ( $validation_error_id ) {
|
784 |
+
$list_item = sprintf(
|
785 |
+
'<li id="%1$s">%2$s</li>',
|
786 |
+
esc_attr( $validation_error_id ),
|
787 |
+
$list_item
|
788 |
+
);
|
789 |
|
790 |
+
$validation_errors[] = $list_item;
|
791 |
+
}
|
792 |
}
|
793 |
}
|
794 |
}
|
includes/form-tag.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* A form-tag.
|
5 |
*
|
6 |
-
* @
|
7 |
*/
|
8 |
class WPCF7_FormTag implements ArrayAccess {
|
9 |
|
@@ -511,8 +511,9 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
511 |
/**
|
512 |
* Assigns a value to the specified offset.
|
513 |
*
|
514 |
-
* @
|
515 |
*/
|
|
|
516 |
public function offsetSet( $offset, $value ) {
|
517 |
if ( property_exists( __CLASS__, $offset ) ) {
|
518 |
$this->{$offset} = $value;
|
@@ -523,8 +524,9 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
523 |
/**
|
524 |
* Returns the value at specified offset.
|
525 |
*
|
526 |
-
* @
|
527 |
*/
|
|
|
528 |
public function offsetGet( $offset ) {
|
529 |
if ( property_exists( __CLASS__, $offset ) ) {
|
530 |
return $this->{$offset};
|
@@ -537,8 +539,9 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
537 |
/**
|
538 |
* Returns true if the specified offset exists.
|
539 |
*
|
540 |
-
* @
|
541 |
*/
|
|
|
542 |
public function offsetExists( $offset ) {
|
543 |
return property_exists( __CLASS__, $offset );
|
544 |
}
|
@@ -547,8 +550,9 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
547 |
/**
|
548 |
* Unsets an offset.
|
549 |
*
|
550 |
-
* @
|
551 |
*/
|
|
|
552 |
public function offsetUnset( $offset ) {
|
553 |
}
|
554 |
|
3 |
/**
|
4 |
* A form-tag.
|
5 |
*
|
6 |
+
* @link https://contactform7.com/tag-syntax/#form_tag
|
7 |
*/
|
8 |
class WPCF7_FormTag implements ArrayAccess {
|
9 |
|
511 |
/**
|
512 |
* Assigns a value to the specified offset.
|
513 |
*
|
514 |
+
* @link https://www.php.net/manual/en/arrayaccess.offsetset.php
|
515 |
*/
|
516 |
+
#[ReturnTypeWillChange]
|
517 |
public function offsetSet( $offset, $value ) {
|
518 |
if ( property_exists( __CLASS__, $offset ) ) {
|
519 |
$this->{$offset} = $value;
|
524 |
/**
|
525 |
* Returns the value at specified offset.
|
526 |
*
|
527 |
+
* @link https://www.php.net/manual/en/arrayaccess.offsetget.php
|
528 |
*/
|
529 |
+
#[ReturnTypeWillChange]
|
530 |
public function offsetGet( $offset ) {
|
531 |
if ( property_exists( __CLASS__, $offset ) ) {
|
532 |
return $this->{$offset};
|
539 |
/**
|
540 |
* Returns true if the specified offset exists.
|
541 |
*
|
542 |
+
* @link https://www.php.net/manual/en/arrayaccess.offsetexists.php
|
543 |
*/
|
544 |
+
#[ReturnTypeWillChange]
|
545 |
public function offsetExists( $offset ) {
|
546 |
return property_exists( __CLASS__, $offset );
|
547 |
}
|
550 |
/**
|
551 |
* Unsets an offset.
|
552 |
*
|
553 |
+
* @link https://www.php.net/manual/en/arrayaccess.offsetunset.php
|
554 |
*/
|
555 |
+
#[ReturnTypeWillChange]
|
556 |
public function offsetUnset( $offset ) {
|
557 |
}
|
558 |
|
includes/functions.php
CHANGED
@@ -462,7 +462,7 @@ function wpcf7_rmdir_p( $dir ) {
|
|
462 |
/**
|
463 |
* Builds a URL-encoded query string.
|
464 |
*
|
465 |
-
* @
|
466 |
*
|
467 |
* @param array $args URL query parameters.
|
468 |
* @param string $key Optional. If specified, used to prefix key name.
|
@@ -499,7 +499,7 @@ function wpcf7_build_query( $args, $key = '' ) {
|
|
499 |
/**
|
500 |
* Returns the number of code units in a string.
|
501 |
*
|
502 |
-
* @
|
503 |
*
|
504 |
* @param string $text Input string.
|
505 |
* @return int|bool The number of code units, or false if
|
462 |
/**
|
463 |
* Builds a URL-encoded query string.
|
464 |
*
|
465 |
+
* @link https://developer.wordpress.org/reference/functions/_http_build_query/
|
466 |
*
|
467 |
* @param array $args URL query parameters.
|
468 |
* @param string $key Optional. If specified, used to prefix key name.
|
499 |
/**
|
500 |
* Returns the number of code units in a string.
|
501 |
*
|
502 |
+
* @link http://www.w3.org/TR/html5/infrastructure.html#code-unit-length
|
503 |
*
|
504 |
* @param string $text Input string.
|
505 |
* @return int|bool The number of code units, or false if
|
includes/js/index.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(){"use strict";var e={d:function(t,n){for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{date:function(){return m},email:function(){return p},file:function(){return h},maxdate:function(){return x},maxfilesize:function(){return A},maxlength:function(){return v},maxnumber:function(){return b},mindate:function(){return y},minlength:function(){return w},minnumber:function(){return g},number:function(){return u},required:function(){return c},requiredfile:function(){return l},tel:function(){return f},url:function(){return d}});const n=e=>Math.abs(parseInt(e,10)),a=(e,t)=>{const n=new Map([["init","init"],["validation_failed","invalid"],["acceptance_missing","unaccepted"],["spam","spam"],["aborted","aborted"],["mail_sent","sent"],["mail_failed","failed"],["submitting","submitting"],["resetting","resetting"],["validating","validating"],["payment_required","payment-required"]]);n.has(t)&&(t=n.get(t)),Array.from(n.values()).includes(t)||(t=`custom-${t=(t=t.replace(/[^0-9a-z]+/i," ").trim()).replace(/\s+/,"-")}`);const a=e.getAttribute("data-status");return e.wpcf7.status=t,e.setAttribute("data-status",t),e.classList.add(t),a&&a!==t&&e.classList.remove(a),t},o=(e,t,n)=>{const a=new CustomEvent(`wpcf7${t}`,{bubbles:!0,detail:n});"string"==typeof e&&(e=document.querySelector(e)),e.dispatchEvent(a)},i=e=>{const{root:t,namespace:n="contact-form-7/v1"}=wpcf7.api,a=s.reduceRight(((e,t)=>n=>t(n,e)),(e=>{let a,o,{url:i,path:s,endpoint:r,headers:c,body:l,data:p,...d}=e;"string"==typeof r&&(a=n.replace(/^\/|\/$/g,""),o=r.replace(/^\//,""),s=o?a+"/"+o:a),"string"==typeof s&&(-1!==t.indexOf("?")&&(s=s.replace("?","&")),s=s.replace(/^\//,""),i=t+s),c={Accept:"application/json, */*;q=0.1",...c},delete c["X-WP-Nonce"],p&&(l=JSON.stringify(p),c["Content-Type"]="application/json");const f={code:"fetch_error",message:"You are probably offline."},u={code:"invalid_json",message:"The response is not a valid JSON response."};return window.fetch(i||s||window.location.href,{...d,headers:c,body:l}).then((e=>Promise.resolve(e).then((e=>{if(e.status>=200&&e.status<300)return e;throw e})).then((e=>{if(204===e.status)return null;if(e&&e.json)return e.json().catch((()=>{throw u}));throw u}))),(()=>{throw f}))}));return a(e)},s=[];function r(e){let{rule:t,field:n,error:a,...o}=e;this.rule=t,this.field=n,this.error=a,this.properties=o}i.use=e=>{s.unshift(e)};const c=function(e){if(0===e.getAll(this.field).length)throw new r(this)},l=function(e){if(0===e.getAll(this.field).length)throw new r(this)},p=function(e){if(!e.getAll(this.field).every((e=>{if((e=e.trim()).length<6)return!1;if(-1===e.indexOf("@",1))return!1;if(e.indexOf("@")!==e.lastIndexOf("@"))return!1;const[t,n]=e.split("@",2);if(!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/.test(t))return!1;if(/\.{2,}/.test(n))return!1;if(/(?:^[ \t\n\r\0\x0B.]|[ \t\n\r\0\x0B.]$)/.test(n))return!1;const a=n.split(".");if(a.length<2)return!1;for(const e of a){if(/(?:^[ \t\n\r\0\x0B-]|[ \t\n\r\0\x0B-]$)/.test(e))return!1;if(!/^[a-z0-9-]+$/i.test(e))return!1}return!0})))throw new r(this)},d=function(e){const t=e.getAll(this.field);if(!t.every((e=>{if(""===(e=e.trim()))return!1;try{return(e=>-1!==["http","https","ftp","ftps","mailto","news","irc","irc6","ircs","gopher","nntp","feed","telnet","mms","rtsp","sms","svn","tel","fax","xmpp","webcal","urn"].indexOf(e))(new URL(e).protocol.replace(/:$/,""))}catch{return!1}})))throw new r(this)},f=function(e){if(!e.getAll(this.field).every((e=>(e=(e=e.trim()).replaceAll(/[()/.*#\s-]+/g,""),/^[+]?[0-9]+$/.test(e)))))throw new r(this)},u=function(e){if(!e.getAll(this.field).every((e=>(e=e.trim(),!!/^[-]?[0-9]+(?:[eE][+-]?[0-9]+)?$/.test(e)||!!/^[-]?(?:[0-9]+)?[.][0-9]+(?:[eE][+-]?[0-9]+)?$/.test(e)))))throw new r(this)},m=function(e){if(!e.getAll(this.field).every((e=>/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(e.trim()))))throw new r(this)},h=function(e){if(!e.getAll(this.field).every((e=>{var t;return e instanceof File&&(null===(t=this.accept)||void 0===t?void 0:t.some((t=>/^\.[a-z0-9]+$/i.test(t)?e.name.toLowerCase().endsWith(t.toLowerCase()):(e=>{const t=[],n=e.match(/^(?<toplevel>[a-z]+)\/(?<sub>[*]|[a-z0-9.+-]+)$/i);if(n){const e=n.groups.toplevel.toLowerCase(),a=n.groups.sub.toLowerCase();for(const[o,i]of(()=>{const e=new Map;return e.set("jpg|jpeg|jpe","image/jpeg"),e.set("gif","image/gif"),e.set("png","image/png"),e.set("bmp","image/bmp"),e.set("tiff|tif","image/tiff"),e.set("webp","image/webp"),e.set("ico","image/x-icon"),e.set("heic","image/heic"),e.set("asf|asx","video/x-ms-asf"),e.set("wmv","video/x-ms-wmv"),e.set("wmx","video/x-ms-wmx"),e.set("wm","video/x-ms-wm"),e.set("avi","video/avi"),e.set("divx","video/divx"),e.set("flv","video/x-flv"),e.set("mov|qt","video/quicktime"),e.set("mpeg|mpg|mpe","video/mpeg"),e.set("mp4|m4v","video/mp4"),e.set("ogv","video/ogg"),e.set("webm","video/webm"),e.set("mkv","video/x-matroska"),e.set("3gp|3gpp","video/3gpp"),e.set("3g2|3gp2","video/3gpp2"),e.set("txt|asc|c|cc|h|srt","text/plain"),e.set("csv","text/csv"),e.set("tsv","text/tab-separated-values"),e.set("ics","text/calendar"),e.set("rtx","text/richtext"),e.set("css","text/css"),e.set("htm|html","text/html"),e.set("vtt","text/vtt"),e.set("dfxp","application/ttaf+xml"),e.set("mp3|m4a|m4b","audio/mpeg"),e.set("aac","audio/aac"),e.set("ra|ram","audio/x-realaudio"),e.set("wav","audio/wav"),e.set("ogg|oga","audio/ogg"),e.set("flac","audio/flac"),e.set("mid|midi","audio/midi"),e.set("wma","audio/x-ms-wma"),e.set("wax","audio/x-ms-wax"),e.set("mka","audio/x-matroska"),e.set("rtf","application/rtf"),e.set("js","application/javascript"),e.set("pdf","application/pdf"),e.set("swf","application/x-shockwave-flash"),e.set("class","application/java"),e.set("tar","application/x-tar"),e.set("zip","application/zip"),e.set("gz|gzip","application/x-gzip"),e.set("rar","application/rar"),e.set("7z","application/x-7z-compressed"),e.set("exe","application/x-msdownload"),e.set("psd","application/octet-stream"),e.set("xcf","application/octet-stream"),e.set("doc","application/msword"),e.set("pot|pps|ppt","application/vnd.ms-powerpoint"),e.set("wri","application/vnd.ms-write"),e.set("xla|xls|xlt|xlw","application/vnd.ms-excel"),e.set("mdb","application/vnd.ms-access"),e.set("mpp","application/vnd.ms-project"),e.set("docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"),e.set("docm","application/vnd.ms-word.document.macroEnabled.12"),e.set("dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"),e.set("dotm","application/vnd.ms-word.template.macroEnabled.12"),e.set("xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),e.set("xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"),e.set("xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"),e.set("xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"),e.set("xltm","application/vnd.ms-excel.template.macroEnabled.12"),e.set("xlam","application/vnd.ms-excel.addin.macroEnabled.12"),e.set("pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"),e.set("pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"),e.set("ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"),e.set("ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"),e.set("potx","application/vnd.openxmlformats-officedocument.presentationml.template"),e.set("potm","application/vnd.ms-powerpoint.template.macroEnabled.12"),e.set("ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"),e.set("sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"),e.set("sldm","application/vnd.ms-powerpoint.slide.macroEnabled.12"),e.set("onetoc|onetoc2|onetmp|onepkg","application/onenote"),e.set("oxps","application/oxps"),e.set("xps","application/vnd.ms-xpsdocument"),e.set("odt","application/vnd.oasis.opendocument.text"),e.set("odp","application/vnd.oasis.opendocument.presentation"),e.set("ods","application/vnd.oasis.opendocument.spreadsheet"),e.set("odg","application/vnd.oasis.opendocument.graphics"),e.set("odc","application/vnd.oasis.opendocument.chart"),e.set("odb","application/vnd.oasis.opendocument.database"),e.set("odf","application/vnd.oasis.opendocument.formula"),e.set("wp|wpd","application/wordperfect"),e.set("key","application/vnd.apple.keynote"),e.set("numbers","application/vnd.apple.numbers"),e.set("pages","application/vnd.apple.pages"),e})())("*"===a&&i.startsWith(e+"/")||i===n[0])&&t.push(...o.split("|"))}return t})(t).some((t=>(t="."+t.trim(),e.name.toLowerCase().endsWith(t.toLowerCase())))))))})))throw new r(this)},w=function(e){const t=e.getAll(this.field);let n=0;if(t.forEach((e=>{"string"==typeof e&&(n+=e.length)})),n<parseInt(this.threshold))throw new r(this)},v=function(e){const t=e.getAll(this.field);let n=0;if(t.forEach((e=>{"string"==typeof e&&(n+=e.length)})),parseInt(this.threshold)<n)throw new r(this)},g=function(e){if(!e.getAll(this.field).every((e=>!(parseFloat(e)<parseFloat(this.threshold)))))throw new r(this)},b=function(e){if(!e.getAll(this.field).every((e=>!(parseFloat(this.threshold)<parseFloat(e)))))throw new r(this)},y=function(e){if(!e.getAll(this.field).every((e=>(e=e.trim(),!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(e)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&e<this.threshold)))))throw new r(this)},x=function(e){if(!e.getAll(this.field).every((e=>(e=e.trim(),!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(e)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&this.threshold<e)))))throw new r(this)},A=function(e){const t=e.getAll(this.field);let n=0;if(t.forEach((e=>{e instanceof File&&(n+=e.size)})),parseInt(this.threshold)<n)throw new r(this)};function E(e){if(this.formData={},this.tree={},!(e instanceof FormData))return this;this.formData=e;const t=()=>{const e=new Map;return e.largestIndex=0,e.set=function(t,n){""===t?t=e.largestIndex++:/^[0-9]+$/.test(t)&&(t=parseInt(t),e.largestIndex<=t&&(e.largestIndex=t+1)),Map.prototype.set.call(e,t,n)},e};this.tree=t();const n=/^(?<name>[a-z][-a-z0-9_:]*)(?<array>(?:\[(?:[a-z][-a-z0-9_:]*|[0-9]*)\])*)/i;for(const[e,a]of this.formData){const o=e.match(n);if(o)if(""===o.groups.array)this.tree.set(o.groups.name,a);else{const e=[...o.groups.array.matchAll(/\[([a-z][-a-z0-9_:]*|[0-9]*)\]/gi)].map((e=>{let[t,n]=e;return n}));e.unshift(o.groups.name);const n=e.pop();e.reduce(((e,n)=>{if(/^[0-9]+$/.test(n)&&(n=parseInt(n)),e.get(n)instanceof Map)return e.get(n);const a=t();return e.set(n,a),a}),this.tree).set(n,a)}}}function q(e){var t,n,o,i;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const c=e;if(null===(t=s.target)||void 0===t||!t.closest(".wpcf7-form-control-wrap[data-name]"))return;if(null!==(n=s.target)&&void 0!==n&&n.closest(".novalidate"))return;const l=new FormData,p=[];for(const e of c.querySelectorAll(".wpcf7-form-control-wrap"))if(!e.closest(".novalidate")&&(e.querySelectorAll(":where( input, textarea, select ):enabled").forEach((e=>{if(e.name)switch(e.type){case"button":case"image":case"reset":case"submit":break;case"checkbox":case"radio":e.checked&&l.append(e.name,e.value);break;case"select-multiple":for(const t of e.selectedOptions)l.append(e.name,t.value);break;case"file":for(const t of e.files)l.append(e.name,t);break;default:l.append(e.name,e.value)}})),e.dataset.name&&(p.push(e.dataset.name),e.setAttribute("data-under-validation","1"),e.dataset.name===s.target.name.replace(/\[.*\]$/,""))))break;const d=null!==(o=q.validators)&&void 0!==o?o:{},f=(null!==(i=e.wpcf7.schema.rules)&&void 0!==i?i:[]).filter((e=>{let{rule:t,...n}=e;return"function"==typeof d[t]&&("function"==typeof d[t].matches?d[t].matches(n,s):p.includes(n.field))}));if(!f.length)return;const u=e.getAttribute("data-status");Promise.resolve(a(e,"validating")).then((t=>{const n=[],a=new E(l);for(const{rule:t,...o}of f)if(!n.includes(o.field))try{_(e,o.field),d[t].call({rule:t,...o},a)}catch(t){t instanceof r&&(S(e,o.field,t.error),n.push(o.field))}})).finally((()=>{a(e,u),e.querySelectorAll(".wpcf7-form-control-wrap[data-under-validation]").forEach((e=>{e.removeAttribute("data-under-validation")}))}))}E.prototype.entries=function(){return this.tree.entries()},E.prototype.get=function(e){return this.tree.get(e)},E.prototype.getAll=function(e){if(!this.has(e))return[];const t=e=>{const n=[];if(e instanceof Map)for(const[a,o]of e)n.push(...t(o));else""!==e&&n.push(e);return n};return t(this.get(e))},E.prototype.has=function(e){return this.tree.has(e)},E.prototype.keys=function(){return this.tree.keys()},E.prototype.values=function(){return this.tree.values()},q.validators=t;const S=(e,t,n)=>{var a;const o=`${null===(a=e.wpcf7)||void 0===a?void 0:a.unitTag}-ve-${t}`,i=e.querySelector(`.wpcf7-form-control-wrap[data-name="${t}"] .wpcf7-form-control`);(()=>{const t=document.createElement("li");t.setAttribute("id",o),i&&i.id?t.insertAdjacentHTML("beforeend",`<a href="#${i.id}">${n}</a>`):t.insertAdjacentText("beforeend",n),e.wpcf7.parent.querySelector(".screen-reader-response ul").appendChild(t)})(),e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((t=>{if("validating"===e.getAttribute("data-status")&&!t.dataset.underValidation)return;const a=document.createElement("span");a.classList.add("wpcf7-not-valid-tip"),a.setAttribute("aria-hidden","true"),a.insertAdjacentText("beforeend",n),t.appendChild(a),t.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","true")})),t.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.classList.add("wpcf7-not-valid"),e.setAttribute("aria-describedby",o),"function"==typeof e.setCustomValidity&&e.setCustomValidity(n),e.closest(".use-floating-validation-tip")&&(e.addEventListener("focus",(e=>{a.setAttribute("style","display: none")})),a.addEventListener("click",(e=>{a.setAttribute("style","display: none")})))}))}))},_=(e,t)=>{var n,a;const o=`${null===(n=e.wpcf7)||void 0===n?void 0:n.unitTag}-ve-${t}`;null===(a=e.wpcf7.parent.querySelector(`.screen-reader-response ul li#${o}`))||void 0===a||a.remove(),e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((e=>{var t;null===(t=e.querySelector(".wpcf7-not-valid-tip"))||void 0===t||t.remove(),e.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","false")})),e.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.removeAttribute("aria-describedby"),e.classList.remove("wpcf7-not-valid"),"function"==typeof e.setCustomValidity&&e.setCustomValidity("")}))}))};function $(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(wpcf7.blocked)return L(e),void a(e,"submitting");const n=new FormData(e);t.submitter&&t.submitter.name&&n.append(t.submitter.name,t.submitter.value);const s={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(n,(e=>{const t=e[0],n=e[1];return!t.match(/^_/)&&{name:t,value:n}})).filter((e=>!1!==e)),formData:n};i({endpoint:`contact-forms/${e.wpcf7.id}/feedback`,method:"POST",body:n,wpcf7:{endpoint:"feedback",form:e,detail:s}}).then((t=>{const n=a(e,t.status);return s.status=t.status,s.apiResponse=t,["invalid","unaccepted","spam","aborted"].includes(n)?o(e,n,s):["sent","failed"].includes(n)&&o(e,`mail${n}`,s),o(e,"submit",s),t})).then((t=>{t.posted_data_hash&&(e.querySelector('input[name="_wpcf7_posted_data_hash"]').value=t.posted_data_hash),"mail_sent"===t.status&&(e.reset(),e.wpcf7.resetOnMailSent=!0),t.invalid_fields&&t.invalid_fields.forEach((t=>{S(e,t.field,t.message)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').insertAdjacentText("beforeend",t.message),e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=t.message}))})).catch((e=>console.error(e)))}i.use(((e,t)=>{if(e.wpcf7&&"feedback"===e.wpcf7.endpoint){const{form:t,detail:n}=e.wpcf7;L(t),o(t,"beforesubmit",n),a(t,"submitting")}return t(e)}));const L=e=>{e.querySelectorAll(".wpcf7-form-control-wrap").forEach((t=>{t.dataset.name&&_(e,t.dataset.name)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').innerText="",e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=""}))};function k(e){const t=new FormData(e),n={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(t,(e=>{const t=e[0],n=e[1];return!t.match(/^_/)&&{name:t,value:n}})).filter((e=>!1!==e)),formData:t};i({endpoint:`contact-forms/${e.wpcf7.id}/refill`,method:"GET",wpcf7:{endpoint:"refill",form:e,detail:n}}).then((t=>{e.wpcf7.resetOnMailSent?(delete e.wpcf7.resetOnMailSent,a(e,"mail_sent")):a(e,"init"),n.apiResponse=t,o(e,"reset",n)})).catch((e=>console.error(e)))}i.use(((e,t)=>{if(e.wpcf7&&"refill"===e.wpcf7.endpoint){const{form:t,detail:n}=e.wpcf7;L(t),a(t,"resetting")}return t(e)}));const z=(e,t)=>{for(const n in t){const a=t[n];e.querySelectorAll(`input[name="${n}"]`).forEach((e=>{e.value=""})),e.querySelectorAll(`img.wpcf7-captcha-${n}`).forEach((e=>{e.setAttribute("src",a)}));const o=/([0-9]+)\.(png|gif|jpeg)$/.exec(a);o&&e.querySelectorAll(`input[name="_wpcf7_captcha_challenge_${n}"]`).forEach((e=>{e.value=o[1]}))}},j=(e,t)=>{for(const n in t){const a=t[n][0],o=t[n][1];e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${n}"]`).forEach((e=>{e.querySelector(`input[name="${n}"]`).value="",e.querySelector(".wpcf7-quiz-label").textContent=a,e.querySelector(`input[name="_wpcf7_quiz_answer_${n}"]`).value=o}))}};function T(e){const t=new FormData(e);e.wpcf7={id:n(t.get("_wpcf7")),status:e.getAttribute("data-status"),pluginVersion:t.get("_wpcf7_version"),locale:t.get("_wpcf7_locale"),unitTag:t.get("_wpcf7_unit_tag"),containerPost:n(t.get("_wpcf7_container_post")),parent:e.closest(".wpcf7"),schema:{}},e.querySelectorAll(".has-spinner").forEach((e=>{e.insertAdjacentHTML("afterend",'<span class="wpcf7-spinner"></span>')})),(e=>{e.querySelectorAll(".wpcf7-exclusive-checkbox").forEach((t=>{t.addEventListener("change",(t=>{const n=t.target.getAttribute("name");e.querySelectorAll(`input[type="checkbox"][name="${n}"]`).forEach((e=>{e!==t.target&&(e.checked=!1)}))}))}))})(e),(e=>{e.querySelectorAll(".has-free-text").forEach((t=>{const n=t.querySelector("input.wpcf7-free-text"),a=t.querySelector('input[type="checkbox"], input[type="radio"]');n.disabled=!a.checked,e.addEventListener("change",(e=>{n.disabled=!a.checked,e.target===a&&a.checked&&n.focus()}))}))})(e),(e=>{e.querySelectorAll(".wpcf7-validates-as-url").forEach((e=>{e.addEventListener("change",(t=>{let n=e.value.trim();n&&!n.match(/^[a-z][a-z0-9.+-]*:/i)&&-1!==n.indexOf(".")&&(n=n.replace(/^\/+/,""),n="http://"+n),e.value=n}))}))})(e),(e=>{if(!e.querySelector(".wpcf7-acceptance")||e.classList.contains("wpcf7-acceptance-as-validation"))return;const t=()=>{let t=!0;e.querySelectorAll(".wpcf7-acceptance").forEach((e=>{if(!t||e.classList.contains("optional"))return;const n=e.querySelector('input[type="checkbox"]');(e.classList.contains("invert")&&n.checked||!e.classList.contains("invert")&&!n.checked)&&(t=!1)})),e.querySelectorAll(".wpcf7-submit").forEach((e=>{e.disabled=!t}))};t(),e.addEventListener("change",(e=>{t()})),e.addEventListener("wpcf7reset",(e=>{t()}))})(e),(e=>{const t=(e,t)=>{const a=n(e.getAttribute("data-starting-value")),o=n(e.getAttribute("data-maximum-value")),i=n(e.getAttribute("data-minimum-value")),s=e.classList.contains("down")?a-t.value.length:t.value.length;e.setAttribute("data-current-value",s),e.innerText=s,o&&o<t.value.length?e.classList.add("too-long"):e.classList.remove("too-long"),i&&t.value.length<i?e.classList.add("too-short"):e.classList.remove("too-short")},a=n=>{n={init:!1,...n},e.querySelectorAll(".wpcf7-character-count").forEach((a=>{const o=a.getAttribute("data-target-name"),i=e.querySelector(`[name="${o}"]`);i&&(i.value=i.defaultValue,t(a,i),n.init&&i.addEventListener("keyup",(e=>{t(a,i)})))}))};a({init:!0}),e.addEventListener("wpcf7reset",(e=>{a()}))})(e),window.addEventListener("load",(t=>{wpcf7.cached&&e.reset()})),e.addEventListener("reset",(t=>{wpcf7.reset(e)})),e.addEventListener("submit",(t=>{wpcf7.submit(e,{submitter:t.submitter}),t.preventDefault()})),e.addEventListener("wpcf7submit",(t=>{t.detail.apiResponse.captcha&&z(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&j(e,t.detail.apiResponse.quiz)})),e.addEventListener("wpcf7reset",(t=>{t.detail.apiResponse.captcha&&z(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&j(e,t.detail.apiResponse.quiz)})),i({endpoint:`contact-forms/${e.wpcf7.id}/feedback/schema`,method:"GET"}).then((t=>{e.wpcf7.schema=t})),e.addEventListener("change",(t=>{t.target.closest(".wpcf7-form-control")&&wpcf7.validate(e,{target:t.target})}))}document.addEventListener("DOMContentLoaded",(e=>{var t;if("undefined"==typeof wpcf7)return void console.error("wpcf7 is not defined.");if(void 0===wpcf7.api)return void console.error("wpcf7.api is not defined.");if("function"!=typeof window.fetch)return void console.error("Your browser does not support window.fetch().");if("function"!=typeof window.FormData)return void console.error("Your browser does not support window.FormData().");const n=document.querySelectorAll(".wpcf7 > form");"function"==typeof n.forEach?(wpcf7={init:T,submit:$,reset:k,validate:q,...null!==(t=wpcf7)&&void 0!==t?t:{}},n.forEach((e=>wpcf7.init(e)))):console.error("Your browser does not support NodeList.forEach().")}))}();
|
1 |
+
!function(){"use strict";var e={d:function(t,n){for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{date:function(){return m},email:function(){return p},file:function(){return h},maxdate:function(){return x},maxfilesize:function(){return A},maxlength:function(){return v},maxnumber:function(){return b},mindate:function(){return y},minlength:function(){return w},minnumber:function(){return g},number:function(){return u},required:function(){return c},requiredfile:function(){return l},tel:function(){return f},url:function(){return d}});const n=e=>Math.abs(parseInt(e,10)),a=(e,t)=>{const n=new Map([["init","init"],["validation_failed","invalid"],["acceptance_missing","unaccepted"],["spam","spam"],["aborted","aborted"],["mail_sent","sent"],["mail_failed","failed"],["submitting","submitting"],["resetting","resetting"],["validating","validating"],["payment_required","payment-required"]]);n.has(t)&&(t=n.get(t)),Array.from(n.values()).includes(t)||(t=`custom-${t=(t=t.replace(/[^0-9a-z]+/i," ").trim()).replace(/\s+/,"-")}`);const a=e.getAttribute("data-status");return e.wpcf7.status=t,e.setAttribute("data-status",t),e.classList.add(t),a&&a!==t&&e.classList.remove(a),t},o=(e,t,n)=>{const a=new CustomEvent(`wpcf7${t}`,{bubbles:!0,detail:n});"string"==typeof e&&(e=document.querySelector(e)),e.dispatchEvent(a)},i=e=>{const{root:t,namespace:n="contact-form-7/v1"}=wpcf7.api,a=s.reduceRight(((e,t)=>n=>t(n,e)),(e=>{let a,o,{url:i,path:s,endpoint:r,headers:c,body:l,data:p,...d}=e;"string"==typeof r&&(a=n.replace(/^\/|\/$/g,""),o=r.replace(/^\//,""),s=o?a+"/"+o:a),"string"==typeof s&&(-1!==t.indexOf("?")&&(s=s.replace("?","&")),s=s.replace(/^\//,""),i=t+s),c={Accept:"application/json, */*;q=0.1",...c},delete c["X-WP-Nonce"],p&&(l=JSON.stringify(p),c["Content-Type"]="application/json");const f={code:"fetch_error",message:"You are probably offline."},u={code:"invalid_json",message:"The response is not a valid JSON response."};return window.fetch(i||s||window.location.href,{...d,headers:c,body:l}).then((e=>Promise.resolve(e).then((e=>{if(e.status>=200&&e.status<300)return e;throw e})).then((e=>{if(204===e.status)return null;if(e&&e.json)return e.json().catch((()=>{throw u}));throw u}))),(()=>{throw f}))}));return a(e)},s=[];function r(e){let{rule:t,field:n,error:a,...o}=e;this.rule=t,this.field=n,this.error=a,this.properties=o}i.use=e=>{s.unshift(e)};const c=function(e){if(0===e.getAll(this.field).length)throw new r(this)},l=function(e){if(0===e.getAll(this.field).length)throw new r(this)},p=function(e){if(!e.getAll(this.field).every((e=>{if((e=e.trim()).length<6)return!1;if(-1===e.indexOf("@",1))return!1;if(e.indexOf("@")!==e.lastIndexOf("@"))return!1;const[t,n]=e.split("@",2);if(!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/.test(t))return!1;if(/\.{2,}/.test(n))return!1;if(/(?:^[ \t\n\r\0\x0B.]|[ \t\n\r\0\x0B.]$)/.test(n))return!1;const a=n.split(".");if(a.length<2)return!1;for(const e of a){if(/(?:^[ \t\n\r\0\x0B-]|[ \t\n\r\0\x0B-]$)/.test(e))return!1;if(!/^[a-z0-9-]+$/i.test(e))return!1}return!0})))throw new r(this)},d=function(e){const t=e.getAll(this.field);if(!t.every((e=>{if(""===(e=e.trim()))return!1;try{return(e=>-1!==["http","https","ftp","ftps","mailto","news","irc","irc6","ircs","gopher","nntp","feed","telnet","mms","rtsp","sms","svn","tel","fax","xmpp","webcal","urn"].indexOf(e))(new URL(e).protocol.replace(/:$/,""))}catch{return!1}})))throw new r(this)},f=function(e){if(!e.getAll(this.field).every((e=>(e=(e=e.trim()).replaceAll(/[()/.*#\s-]+/g,""),/^[+]?[0-9]+$/.test(e)))))throw new r(this)},u=function(e){if(!e.getAll(this.field).every((e=>(e=e.trim(),!!/^[-]?[0-9]+(?:[eE][+-]?[0-9]+)?$/.test(e)||!!/^[-]?(?:[0-9]+)?[.][0-9]+(?:[eE][+-]?[0-9]+)?$/.test(e)))))throw new r(this)},m=function(e){if(!e.getAll(this.field).every((e=>/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(e.trim()))))throw new r(this)},h=function(e){if(!e.getAll(this.field).every((e=>{var t;return e instanceof File&&(null===(t=this.accept)||void 0===t?void 0:t.some((t=>/^\.[a-z0-9]+$/i.test(t)?e.name.toLowerCase().endsWith(t.toLowerCase()):(e=>{const t=[],n=e.match(/^(?<toplevel>[a-z]+)\/(?<sub>[*]|[a-z0-9.+-]+)$/i);if(n){const e=n.groups.toplevel.toLowerCase(),a=n.groups.sub.toLowerCase();for(const[o,i]of(()=>{const e=new Map;return e.set("jpg|jpeg|jpe","image/jpeg"),e.set("gif","image/gif"),e.set("png","image/png"),e.set("bmp","image/bmp"),e.set("tiff|tif","image/tiff"),e.set("webp","image/webp"),e.set("ico","image/x-icon"),e.set("heic","image/heic"),e.set("asf|asx","video/x-ms-asf"),e.set("wmv","video/x-ms-wmv"),e.set("wmx","video/x-ms-wmx"),e.set("wm","video/x-ms-wm"),e.set("avi","video/avi"),e.set("divx","video/divx"),e.set("flv","video/x-flv"),e.set("mov|qt","video/quicktime"),e.set("mpeg|mpg|mpe","video/mpeg"),e.set("mp4|m4v","video/mp4"),e.set("ogv","video/ogg"),e.set("webm","video/webm"),e.set("mkv","video/x-matroska"),e.set("3gp|3gpp","video/3gpp"),e.set("3g2|3gp2","video/3gpp2"),e.set("txt|asc|c|cc|h|srt","text/plain"),e.set("csv","text/csv"),e.set("tsv","text/tab-separated-values"),e.set("ics","text/calendar"),e.set("rtx","text/richtext"),e.set("css","text/css"),e.set("htm|html","text/html"),e.set("vtt","text/vtt"),e.set("dfxp","application/ttaf+xml"),e.set("mp3|m4a|m4b","audio/mpeg"),e.set("aac","audio/aac"),e.set("ra|ram","audio/x-realaudio"),e.set("wav","audio/wav"),e.set("ogg|oga","audio/ogg"),e.set("flac","audio/flac"),e.set("mid|midi","audio/midi"),e.set("wma","audio/x-ms-wma"),e.set("wax","audio/x-ms-wax"),e.set("mka","audio/x-matroska"),e.set("rtf","application/rtf"),e.set("js","application/javascript"),e.set("pdf","application/pdf"),e.set("swf","application/x-shockwave-flash"),e.set("class","application/java"),e.set("tar","application/x-tar"),e.set("zip","application/zip"),e.set("gz|gzip","application/x-gzip"),e.set("rar","application/rar"),e.set("7z","application/x-7z-compressed"),e.set("exe","application/x-msdownload"),e.set("psd","application/octet-stream"),e.set("xcf","application/octet-stream"),e.set("doc","application/msword"),e.set("pot|pps|ppt","application/vnd.ms-powerpoint"),e.set("wri","application/vnd.ms-write"),e.set("xla|xls|xlt|xlw","application/vnd.ms-excel"),e.set("mdb","application/vnd.ms-access"),e.set("mpp","application/vnd.ms-project"),e.set("docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"),e.set("docm","application/vnd.ms-word.document.macroEnabled.12"),e.set("dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"),e.set("dotm","application/vnd.ms-word.template.macroEnabled.12"),e.set("xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),e.set("xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"),e.set("xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"),e.set("xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"),e.set("xltm","application/vnd.ms-excel.template.macroEnabled.12"),e.set("xlam","application/vnd.ms-excel.addin.macroEnabled.12"),e.set("pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"),e.set("pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"),e.set("ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"),e.set("ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"),e.set("potx","application/vnd.openxmlformats-officedocument.presentationml.template"),e.set("potm","application/vnd.ms-powerpoint.template.macroEnabled.12"),e.set("ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"),e.set("sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"),e.set("sldm","application/vnd.ms-powerpoint.slide.macroEnabled.12"),e.set("onetoc|onetoc2|onetmp|onepkg","application/onenote"),e.set("oxps","application/oxps"),e.set("xps","application/vnd.ms-xpsdocument"),e.set("odt","application/vnd.oasis.opendocument.text"),e.set("odp","application/vnd.oasis.opendocument.presentation"),e.set("ods","application/vnd.oasis.opendocument.spreadsheet"),e.set("odg","application/vnd.oasis.opendocument.graphics"),e.set("odc","application/vnd.oasis.opendocument.chart"),e.set("odb","application/vnd.oasis.opendocument.database"),e.set("odf","application/vnd.oasis.opendocument.formula"),e.set("wp|wpd","application/wordperfect"),e.set("key","application/vnd.apple.keynote"),e.set("numbers","application/vnd.apple.numbers"),e.set("pages","application/vnd.apple.pages"),e})())("*"===a&&i.startsWith(e+"/")||i===n[0])&&t.push(...o.split("|"))}return t})(t).some((t=>(t="."+t.trim(),e.name.toLowerCase().endsWith(t.toLowerCase())))))))})))throw new r(this)},w=function(e){const t=e.getAll(this.field);let n=0;if(t.forEach((e=>{"string"==typeof e&&(n+=e.length)})),n<parseInt(this.threshold))throw new r(this)},v=function(e){const t=e.getAll(this.field);let n=0;if(t.forEach((e=>{"string"==typeof e&&(n+=e.length)})),parseInt(this.threshold)<n)throw new r(this)},g=function(e){if(!e.getAll(this.field).every((e=>!(parseFloat(e)<parseFloat(this.threshold)))))throw new r(this)},b=function(e){if(!e.getAll(this.field).every((e=>!(parseFloat(this.threshold)<parseFloat(e)))))throw new r(this)},y=function(e){if(!e.getAll(this.field).every((e=>(e=e.trim(),!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(e)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&e<this.threshold)))))throw new r(this)},x=function(e){if(!e.getAll(this.field).every((e=>(e=e.trim(),!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(e)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&this.threshold<e)))))throw new r(this)},A=function(e){const t=e.getAll(this.field);let n=0;if(t.forEach((e=>{e instanceof File&&(n+=e.size)})),parseInt(this.threshold)<n)throw new r(this)};function E(e){if(this.formData={},this.tree={},!(e instanceof FormData))return this;this.formData=e;const t=()=>{const e=new Map;return e.largestIndex=0,e.set=function(t,n){""===t?t=e.largestIndex++:/^[0-9]+$/.test(t)&&(t=parseInt(t),e.largestIndex<=t&&(e.largestIndex=t+1)),Map.prototype.set.call(e,t,n)},e};this.tree=t();const n=/^(?<name>[a-z][-a-z0-9_:]*)(?<array>(?:\[(?:[a-z][-a-z0-9_:]*|[0-9]*)\])*)/i;for(const[e,a]of this.formData){const o=e.match(n);if(o)if(""===o.groups.array)this.tree.set(o.groups.name,a);else{const e=[...o.groups.array.matchAll(/\[([a-z][-a-z0-9_:]*|[0-9]*)\]/gi)].map((e=>{let[t,n]=e;return n}));e.unshift(o.groups.name);const n=e.pop();e.reduce(((e,n)=>{if(/^[0-9]+$/.test(n)&&(n=parseInt(n)),e.get(n)instanceof Map)return e.get(n);const a=t();return e.set(n,a),a}),this.tree).set(n,a)}}}function q(e){var t,n,o,i;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const c=e;if(null===(t=s.target)||void 0===t||!t.closest(".wpcf7-form-control-wrap[data-name]"))return;if(null!==(n=s.target)&&void 0!==n&&n.closest(".novalidate"))return;const l=new FormData,p=[];for(const e of c.querySelectorAll(".wpcf7-form-control-wrap"))if(!e.closest(".novalidate")&&(e.querySelectorAll(":where( input, textarea, select ):enabled").forEach((e=>{if(e.name)switch(e.type){case"button":case"image":case"reset":case"submit":break;case"checkbox":case"radio":e.checked&&l.append(e.name,e.value);break;case"select-multiple":for(const t of e.selectedOptions)l.append(e.name,t.value);break;case"file":for(const t of e.files)l.append(e.name,t);break;default:l.append(e.name,e.value)}})),e.dataset.name&&(p.push(e.dataset.name),e.setAttribute("data-under-validation","1"),e.dataset.name===s.target.name.replace(/\[.*\]$/,""))))break;const d=null!==(o=q.validators)&&void 0!==o?o:{},f=(null!==(i=e.wpcf7.schema.rules)&&void 0!==i?i:[]).filter((e=>{let{rule:t,...n}=e;return"function"==typeof d[t]&&("function"==typeof d[t].matches?d[t].matches(n,s):p.includes(n.field))}));if(!f.length)return;const u=e.getAttribute("data-status");Promise.resolve(a(e,"validating")).then((t=>{const n=[],a=new E(l);for(const{rule:t,...o}of f)if(!n.includes(o.field))try{_(e,o.field),d[t].call({rule:t,...o},a)}catch(t){t instanceof r&&(S(e,o.field,t.error),n.push(o.field))}})).finally((()=>{a(e,u),e.querySelectorAll(".wpcf7-form-control-wrap[data-under-validation]").forEach((e=>{e.removeAttribute("data-under-validation")}))}))}E.prototype.entries=function(){return this.tree.entries()},E.prototype.get=function(e){return this.tree.get(e)},E.prototype.getAll=function(e){if(!this.has(e))return[];const t=e=>{const n=[];if(e instanceof Map)for(const[a,o]of e)n.push(...t(o));else""!==e&&n.push(e);return n};return t(this.get(e))},E.prototype.has=function(e){return this.tree.has(e)},E.prototype.keys=function(){return this.tree.keys()},E.prototype.values=function(){return this.tree.values()},q.validators=t;const S=(e,t,n)=>{var a;const o=`${null===(a=e.wpcf7)||void 0===a?void 0:a.unitTag}-ve-${t}`.replaceAll(/[^0-9a-z_-]+/gi,""),i=e.querySelector(`.wpcf7-form-control-wrap[data-name="${t}"] .wpcf7-form-control`);(()=>{const t=document.createElement("li");t.setAttribute("id",o),i&&i.id?t.insertAdjacentHTML("beforeend",`<a href="#${i.id}">${n}</a>`):t.insertAdjacentText("beforeend",n),e.wpcf7.parent.querySelector(".screen-reader-response ul").appendChild(t)})(),e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((t=>{if("validating"===e.getAttribute("data-status")&&!t.dataset.underValidation)return;const a=document.createElement("span");a.classList.add("wpcf7-not-valid-tip"),a.setAttribute("aria-hidden","true"),a.insertAdjacentText("beforeend",n),t.appendChild(a),t.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","true")})),t.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.classList.add("wpcf7-not-valid"),e.setAttribute("aria-describedby",o),"function"==typeof e.setCustomValidity&&e.setCustomValidity(n),e.closest(".use-floating-validation-tip")&&(e.addEventListener("focus",(e=>{a.setAttribute("style","display: none")})),a.addEventListener("click",(e=>{a.setAttribute("style","display: none")})))}))}))},_=(e,t)=>{var n,a;const o=`${null===(n=e.wpcf7)||void 0===n?void 0:n.unitTag}-ve-${t}`.replaceAll(/[^0-9a-z_-]+/gi,"");null===(a=e.wpcf7.parent.querySelector(`.screen-reader-response ul li#${o}`))||void 0===a||a.remove(),e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((e=>{var t;null===(t=e.querySelector(".wpcf7-not-valid-tip"))||void 0===t||t.remove(),e.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","false")})),e.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.removeAttribute("aria-describedby"),e.classList.remove("wpcf7-not-valid"),"function"==typeof e.setCustomValidity&&e.setCustomValidity("")}))}))};function $(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(wpcf7.blocked)return L(e),void a(e,"submitting");const n=new FormData(e);t.submitter&&t.submitter.name&&n.append(t.submitter.name,t.submitter.value);const s={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(n,(e=>{const t=e[0],n=e[1];return!t.match(/^_/)&&{name:t,value:n}})).filter((e=>!1!==e)),formData:n};i({endpoint:`contact-forms/${e.wpcf7.id}/feedback`,method:"POST",body:n,wpcf7:{endpoint:"feedback",form:e,detail:s}}).then((t=>{const n=a(e,t.status);return s.status=t.status,s.apiResponse=t,["invalid","unaccepted","spam","aborted"].includes(n)?o(e,n,s):["sent","failed"].includes(n)&&o(e,`mail${n}`,s),o(e,"submit",s),t})).then((t=>{t.posted_data_hash&&(e.querySelector('input[name="_wpcf7_posted_data_hash"]').value=t.posted_data_hash),"mail_sent"===t.status&&(e.reset(),e.wpcf7.resetOnMailSent=!0),t.invalid_fields&&t.invalid_fields.forEach((t=>{S(e,t.field,t.message)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').insertAdjacentText("beforeend",t.message),e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=t.message}))})).catch((e=>console.error(e)))}i.use(((e,t)=>{if(e.wpcf7&&"feedback"===e.wpcf7.endpoint){const{form:t,detail:n}=e.wpcf7;L(t),o(t,"beforesubmit",n),a(t,"submitting")}return t(e)}));const L=e=>{e.querySelectorAll(".wpcf7-form-control-wrap").forEach((t=>{t.dataset.name&&_(e,t.dataset.name)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').innerText="",e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=""}))};function k(e){const t=new FormData(e),n={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(t,(e=>{const t=e[0],n=e[1];return!t.match(/^_/)&&{name:t,value:n}})).filter((e=>!1!==e)),formData:t};i({endpoint:`contact-forms/${e.wpcf7.id}/refill`,method:"GET",wpcf7:{endpoint:"refill",form:e,detail:n}}).then((t=>{e.wpcf7.resetOnMailSent?(delete e.wpcf7.resetOnMailSent,a(e,"mail_sent")):a(e,"init"),n.apiResponse=t,o(e,"reset",n)})).catch((e=>console.error(e)))}i.use(((e,t)=>{if(e.wpcf7&&"refill"===e.wpcf7.endpoint){const{form:t,detail:n}=e.wpcf7;L(t),a(t,"resetting")}return t(e)}));const z=(e,t)=>{for(const n in t){const a=t[n];e.querySelectorAll(`input[name="${n}"]`).forEach((e=>{e.value=""})),e.querySelectorAll(`img.wpcf7-captcha-${n.replaceAll(":","")}`).forEach((e=>{e.setAttribute("src",a)}));const o=/([0-9]+)\.(png|gif|jpeg)$/.exec(a);o&&e.querySelectorAll(`input[name="_wpcf7_captcha_challenge_${n}"]`).forEach((e=>{e.value=o[1]}))}},j=(e,t)=>{for(const n in t){const a=t[n][0],o=t[n][1];e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${n}"]`).forEach((e=>{e.querySelector(`input[name="${n}"]`).value="",e.querySelector(".wpcf7-quiz-label").textContent=a,e.querySelector(`input[name="_wpcf7_quiz_answer_${n}"]`).value=o}))}};function T(e){const t=new FormData(e);e.wpcf7={id:n(t.get("_wpcf7")),status:e.getAttribute("data-status"),pluginVersion:t.get("_wpcf7_version"),locale:t.get("_wpcf7_locale"),unitTag:t.get("_wpcf7_unit_tag"),containerPost:n(t.get("_wpcf7_container_post")),parent:e.closest(".wpcf7"),schema:{}},e.querySelectorAll(".has-spinner").forEach((e=>{e.insertAdjacentHTML("afterend",'<span class="wpcf7-spinner"></span>')})),(e=>{e.querySelectorAll(".wpcf7-exclusive-checkbox").forEach((t=>{t.addEventListener("change",(t=>{const n=t.target.getAttribute("name");e.querySelectorAll(`input[type="checkbox"][name="${n}"]`).forEach((e=>{e!==t.target&&(e.checked=!1)}))}))}))})(e),(e=>{e.querySelectorAll(".has-free-text").forEach((t=>{const n=t.querySelector("input.wpcf7-free-text"),a=t.querySelector('input[type="checkbox"], input[type="radio"]');n.disabled=!a.checked,e.addEventListener("change",(e=>{n.disabled=!a.checked,e.target===a&&a.checked&&n.focus()}))}))})(e),(e=>{e.querySelectorAll(".wpcf7-validates-as-url").forEach((e=>{e.addEventListener("change",(t=>{let n=e.value.trim();n&&!n.match(/^[a-z][a-z0-9.+-]*:/i)&&-1!==n.indexOf(".")&&(n=n.replace(/^\/+/,""),n="http://"+n),e.value=n}))}))})(e),(e=>{if(!e.querySelector(".wpcf7-acceptance")||e.classList.contains("wpcf7-acceptance-as-validation"))return;const t=()=>{let t=!0;e.querySelectorAll(".wpcf7-acceptance").forEach((e=>{if(!t||e.classList.contains("optional"))return;const n=e.querySelector('input[type="checkbox"]');(e.classList.contains("invert")&&n.checked||!e.classList.contains("invert")&&!n.checked)&&(t=!1)})),e.querySelectorAll(".wpcf7-submit").forEach((e=>{e.disabled=!t}))};t(),e.addEventListener("change",(e=>{t()})),e.addEventListener("wpcf7reset",(e=>{t()}))})(e),(e=>{const t=(e,t)=>{const a=n(e.getAttribute("data-starting-value")),o=n(e.getAttribute("data-maximum-value")),i=n(e.getAttribute("data-minimum-value")),s=e.classList.contains("down")?a-t.value.length:t.value.length;e.setAttribute("data-current-value",s),e.innerText=s,o&&o<t.value.length?e.classList.add("too-long"):e.classList.remove("too-long"),i&&t.value.length<i?e.classList.add("too-short"):e.classList.remove("too-short")},a=n=>{n={init:!1,...n},e.querySelectorAll(".wpcf7-character-count").forEach((a=>{const o=a.getAttribute("data-target-name"),i=e.querySelector(`[name="${o}"]`);i&&(i.value=i.defaultValue,t(a,i),n.init&&i.addEventListener("keyup",(e=>{t(a,i)})))}))};a({init:!0}),e.addEventListener("wpcf7reset",(e=>{a()}))})(e),window.addEventListener("load",(t=>{wpcf7.cached&&e.reset()})),e.addEventListener("reset",(t=>{wpcf7.reset(e)})),e.addEventListener("submit",(t=>{wpcf7.submit(e,{submitter:t.submitter}),t.preventDefault()})),e.addEventListener("wpcf7submit",(t=>{t.detail.apiResponse.captcha&&z(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&j(e,t.detail.apiResponse.quiz)})),e.addEventListener("wpcf7reset",(t=>{t.detail.apiResponse.captcha&&z(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&j(e,t.detail.apiResponse.quiz)})),i({endpoint:`contact-forms/${e.wpcf7.id}/feedback/schema`,method:"GET"}).then((t=>{e.wpcf7.schema=t})),e.addEventListener("change",(t=>{t.target.closest(".wpcf7-form-control")&&wpcf7.validate(e,{target:t.target})}))}document.addEventListener("DOMContentLoaded",(e=>{var t;if("undefined"==typeof wpcf7)return void console.error("wpcf7 is not defined.");if(void 0===wpcf7.api)return void console.error("wpcf7.api is not defined.");if("function"!=typeof window.fetch)return void console.error("Your browser does not support window.fetch().");if("function"!=typeof window.FormData)return void console.error("Your browser does not support window.FormData().");const n=document.querySelectorAll(".wpcf7 > form");"function"==typeof n.forEach?(wpcf7={init:T,submit:$,reset:k,validate:q,...null!==(t=wpcf7)&&void 0!==t?t:{}},n.forEach((e=>wpcf7.init(e)))):console.error("Your browser does not support NodeList.forEach().")}))}();
|
includes/validation-functions.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* and may be followed by any number of letters, digits ([0-9]),
|
8 |
* hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
|
9 |
*
|
10 |
-
* @
|
11 |
*
|
12 |
* @return bool True if it is a valid name, false if not.
|
13 |
*/
|
@@ -48,7 +48,7 @@ function wpcf7_is_tel( $text ) {
|
|
48 |
/**
|
49 |
* Checks whether the given text is a well-formed number.
|
50 |
*
|
51 |
-
* @
|
52 |
*/
|
53 |
function wpcf7_is_number( $text ) {
|
54 |
$result = false;
|
@@ -72,7 +72,7 @@ function wpcf7_is_number( $text ) {
|
|
72 |
/**
|
73 |
* Checks whether the given text is a valid date.
|
74 |
*
|
75 |
-
* @
|
76 |
*/
|
77 |
function wpcf7_is_date( $text ) {
|
78 |
$result = preg_match( '/^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/', $text, $matches );
|
7 |
* and may be followed by any number of letters, digits ([0-9]),
|
8 |
* hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
|
9 |
*
|
10 |
+
* @link http://www.w3.org/TR/html401/types.html#h-6.2
|
11 |
*
|
12 |
* @return bool True if it is a valid name, false if not.
|
13 |
*/
|
48 |
/**
|
49 |
* Checks whether the given text is a well-formed number.
|
50 |
*
|
51 |
+
* @link https://html.spec.whatwg.org/multipage/input.html#number-state-(type=number)
|
52 |
*/
|
53 |
function wpcf7_is_number( $text ) {
|
54 |
$result = false;
|
72 |
/**
|
73 |
* Checks whether the given text is a valid date.
|
74 |
*
|
75 |
+
* @link https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date)
|
76 |
*/
|
77 |
function wpcf7_is_date( $text ) {
|
78 |
$result = preg_match( '/^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/', $text, $matches );
|
includes/validation.php
CHANGED
@@ -93,8 +93,9 @@ class WPCF7_Validation implements ArrayAccess {
|
|
93 |
/**
|
94 |
* Assigns a value to the specified offset.
|
95 |
*
|
96 |
-
* @
|
97 |
*/
|
|
|
98 |
public function offsetSet( $offset, $value ) {
|
99 |
if ( isset( $this->container[$offset] ) ) {
|
100 |
$this->container[$offset] = $value;
|
@@ -112,8 +113,9 @@ class WPCF7_Validation implements ArrayAccess {
|
|
112 |
/**
|
113 |
* Returns the value at specified offset.
|
114 |
*
|
115 |
-
* @
|
116 |
*/
|
|
|
117 |
public function offsetGet( $offset ) {
|
118 |
if ( isset( $this->container[$offset] ) ) {
|
119 |
return $this->container[$offset];
|
@@ -124,8 +126,9 @@ class WPCF7_Validation implements ArrayAccess {
|
|
124 |
/**
|
125 |
* Returns true if the specified offset exists.
|
126 |
*
|
127 |
-
* @
|
128 |
*/
|
|
|
129 |
public function offsetExists( $offset ) {
|
130 |
return isset( $this->container[$offset] );
|
131 |
}
|
@@ -134,8 +137,9 @@ class WPCF7_Validation implements ArrayAccess {
|
|
134 |
/**
|
135 |
* Unsets an offset.
|
136 |
*
|
137 |
-
* @
|
138 |
*/
|
|
|
139 |
public function offsetUnset( $offset ) {
|
140 |
}
|
141 |
|
93 |
/**
|
94 |
* Assigns a value to the specified offset.
|
95 |
*
|
96 |
+
* @link https://www.php.net/manual/en/arrayaccess.offsetset.php
|
97 |
*/
|
98 |
+
#[ReturnTypeWillChange]
|
99 |
public function offsetSet( $offset, $value ) {
|
100 |
if ( isset( $this->container[$offset] ) ) {
|
101 |
$this->container[$offset] = $value;
|
113 |
/**
|
114 |
* Returns the value at specified offset.
|
115 |
*
|
116 |
+
* @link https://www.php.net/manual/en/arrayaccess.offsetget.php
|
117 |
*/
|
118 |
+
#[ReturnTypeWillChange]
|
119 |
public function offsetGet( $offset ) {
|
120 |
if ( isset( $this->container[$offset] ) ) {
|
121 |
return $this->container[$offset];
|
126 |
/**
|
127 |
* Returns true if the specified offset exists.
|
128 |
*
|
129 |
+
* @link https://www.php.net/manual/en/arrayaccess.offsetexists.php
|
130 |
*/
|
131 |
+
#[ReturnTypeWillChange]
|
132 |
public function offsetExists( $offset ) {
|
133 |
return isset( $this->container[$offset] );
|
134 |
}
|
137 |
/**
|
138 |
* Unsets an offset.
|
139 |
*
|
140 |
+
* @link https://www.php.net/manual/en/arrayaccess.offsetunset.php
|
141 |
*/
|
142 |
+
#[ReturnTypeWillChange]
|
143 |
public function offsetUnset( $offset ) {
|
144 |
}
|
145 |
|
modules/really-simple-captcha.php
CHANGED
@@ -45,7 +45,7 @@ function wpcf7_captchac_form_tag_handler( $tag ) {
|
|
45 |
}
|
46 |
|
47 |
$class = wpcf7_form_controls_class( $tag->type );
|
48 |
-
$class .= ' wpcf7-captcha-' . $tag->name;
|
49 |
|
50 |
$atts = array();
|
51 |
$atts['class'] = $tag->get_class_option( $class );
|
@@ -82,8 +82,10 @@ function wpcf7_captchac_form_tag_handler( $tag ) {
|
|
82 |
$prefix = substr( $filename, 0, strrpos( $filename, '.' ) );
|
83 |
|
84 |
$html = sprintf(
|
85 |
-
'<input type="hidden" name="
|
86 |
-
$tag->name
|
|
|
|
|
87 |
);
|
88 |
|
89 |
return $html;
|
45 |
}
|
46 |
|
47 |
$class = wpcf7_form_controls_class( $tag->type );
|
48 |
+
$class .= ' wpcf7-captcha-' . str_replace( ':', '', $tag->name );
|
49 |
|
50 |
$atts = array();
|
51 |
$atts['class'] = $tag->get_class_option( $class );
|
82 |
$prefix = substr( $filename, 0, strrpos( $filename, '.' ) );
|
83 |
|
84 |
$html = sprintf(
|
85 |
+
'<input type="hidden" name="%1$s" value="%2$s" /><img %3$s />',
|
86 |
+
esc_attr( sprintf( '_wpcf7_captcha_challenge_%s', $tag->name ) ),
|
87 |
+
esc_attr( $prefix ),
|
88 |
+
$atts
|
89 |
);
|
90 |
|
91 |
return $html;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://contactform7.com/donate/
|
|
4 |
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
|
5 |
Requires at least: 5.9
|
6 |
Tested up to: 6.0
|
7 |
-
Stable tag: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -77,6 +77,10 @@ Do you have questions or issues with Contact Form 7? Use these support channels
|
|
77 |
|
78 |
For more information, see [Releases](https://contactform7.com/category/releases/).
|
79 |
|
|
|
|
|
|
|
|
|
80 |
= 5.6 =
|
81 |
|
82 |
[https://contactform7.com/contact-form-7-56/](https://contactform7.com/contact-form-7-56/)
|
4 |
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
|
5 |
Requires at least: 5.9
|
6 |
Tested up to: 6.0
|
7 |
+
Stable tag: 5.6.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
77 |
|
78 |
For more information, see [Releases](https://contactform7.com/category/releases/).
|
79 |
|
80 |
+
= 5.6.1 =
|
81 |
+
|
82 |
+
[https://contactform7.com/contact-form-7-561/](https://contactform7.com/contact-form-7-561/)
|
83 |
+
|
84 |
= 5.6 =
|
85 |
|
86 |
[https://contactform7.com/contact-form-7-56/](https://contactform7.com/contact-form-7-56/)
|
wp-contact-form-7.php
CHANGED
@@ -7,10 +7,10 @@ Author: Takayuki Miyoshi
|
|
7 |
Author URI: https://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
-
Version: 5.6
|
11 |
*/
|
12 |
|
13 |
-
define( 'WPCF7_VERSION', '5.6' );
|
14 |
|
15 |
define( 'WPCF7_REQUIRED_WP_VERSION', '5.9' );
|
16 |
|
7 |
Author URI: https://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
+
Version: 5.6.1
|
11 |
*/
|
12 |
|
13 |
+
define( 'WPCF7_VERSION', '5.6.1' );
|
14 |
|
15 |
define( 'WPCF7_REQUIRED_WP_VERSION', '5.9' );
|
16 |
|