Version Description
- Submission: Introduces the
$posted_data_hash
and$skip_spam_check
properties. - Submission: Introduces the
wpcf7_skip_spam_check
filter hook. - Contact form: Introduces the
pref()
method. - REST API: Adds parsed form-tags data to the response.
- REST API: Deprecates the
wpcf7_ajax_json_echo
andwpcf7_ajax_onload
filter hooks and introduces thewpcf7_feedback_response
andwpcf7_refill_response
filter hooks as alternatives. - Frontend CSS: Style rules for the response output refer to the
form
elementsclass
attribute. - Frontend JavaScript: Abolishes the use of jQuery events.
- reCAPTCHA: Moves script code to a separate file.
- reCAPTCHA: Changes the name of the field for reCAPTCHA response token from
g-recaptcha-response
to_wpcf7_recaptcha_response
.
Download this release
Release Info
Developer | takayukister |
Plugin | Contact Form 7 |
Version | 5.2 |
Comparing to | |
See all releases |
Code changes from version 5.1.9 to 5.2
- admin/admin.php +3 -2
- admin/includes/class-contact-forms-list-table.php +9 -13
- includes/config-validator.php +1 -1
- includes/contact-form.php +35 -47
- includes/css/styles.css +19 -19
- includes/form-tag.php +4 -8
- includes/formatting.php +1 -1
- includes/functions.php +31 -2
- includes/js/scripts.js +41 -51
- includes/mail.php +13 -5
- includes/pipe.php +12 -0
- includes/rest-api.php +100 -20
- includes/special-mail-tags.php +2 -6
- includes/submission.php +189 -93
- modules/checkbox.php +1 -55
- modules/file.php +28 -7
- modules/flamingo.php +8 -22
- modules/quiz.php +3 -3
- modules/really-simple-captcha.php +3 -3
- modules/{recaptcha.php → recaptcha/recaptcha.php} +31 -95
- modules/recaptcha/script.js +53 -0
- readme.txt +14 -64
- settings.php +12 -4
- wp-contact-form-7.php +3 -3
admin/admin.php
CHANGED
@@ -166,10 +166,11 @@ function wpcf7_dark_mode_support( $user_id ) {
|
|
166 |
}
|
167 |
|
168 |
add_filter( 'set-screen-option', 'wpcf7_set_screen_options', 10, 3 );
|
|
|
169 |
|
170 |
function wpcf7_set_screen_options( $result, $option, $value ) {
|
171 |
$wpcf7_screens = array(
|
172 |
-
'
|
173 |
);
|
174 |
|
175 |
if ( in_array( $option, $wpcf7_screens ) ) {
|
@@ -349,7 +350,7 @@ function wpcf7_load_contact_form_admin() {
|
|
349 |
|
350 |
add_screen_option( 'per_page', array(
|
351 |
'default' => 20,
|
352 |
-
'option' => '
|
353 |
) );
|
354 |
}
|
355 |
}
|
166 |
}
|
167 |
|
168 |
add_filter( 'set-screen-option', 'wpcf7_set_screen_options', 10, 3 );
|
169 |
+
add_filter( 'set_screen_option_wpcf7_contact_forms_per_page', 'wpcf7_set_screen_options', 10, 3 );
|
170 |
|
171 |
function wpcf7_set_screen_options( $result, $option, $value ) {
|
172 |
$wpcf7_screens = array(
|
173 |
+
'wpcf7_contact_forms_per_page',
|
174 |
);
|
175 |
|
176 |
if ( in_array( $option, $wpcf7_screens ) ) {
|
350 |
|
351 |
add_screen_option( 'per_page', array(
|
352 |
'default' => 20,
|
353 |
+
'option' => 'wpcf7_contact_forms_per_page',
|
354 |
) );
|
355 |
}
|
356 |
}
|
admin/includes/class-contact-forms-list-table.php
CHANGED
@@ -28,7 +28,7 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
28 |
|
29 |
public function prepare_items() {
|
30 |
$current_screen = get_current_screen();
|
31 |
-
$per_page = $this->get_items_per_page( '
|
32 |
|
33 |
$args = array(
|
34 |
'posts_per_page' => $per_page,
|
@@ -229,27 +229,23 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
229 |
return;
|
230 |
}
|
231 |
|
232 |
-
$t_time =
|
233 |
-
|
234 |
-
$m_time = $post->post_date;
|
235 |
-
$time = mysql2date( 'G', $post->post_date )
|
236 |
-
- get_option( 'gmt_offset' ) * 3600;
|
237 |
-
|
238 |
$time_diff = time() - $time;
|
239 |
|
240 |
-
if ( $
|
241 |
$h_time = sprintf(
|
242 |
-
/* translators: %s: time since the creation of the contact form */
|
243 |
__( '%s ago', 'contact-form-7' ),
|
244 |
human_time_diff( $time )
|
245 |
);
|
246 |
} else {
|
247 |
-
$h_time =
|
248 |
}
|
249 |
|
250 |
-
return sprintf( '<
|
251 |
-
|
252 |
-
|
253 |
);
|
254 |
}
|
255 |
}
|
28 |
|
29 |
public function prepare_items() {
|
30 |
$current_screen = get_current_screen();
|
31 |
+
$per_page = $this->get_items_per_page( 'wpcf7_contact_forms_per_page' );
|
32 |
|
33 |
$args = array(
|
34 |
'posts_per_page' => $per_page,
|
229 |
return;
|
230 |
}
|
231 |
|
232 |
+
$t_time = get_the_time( __( 'Y/m/d g:i:s a', 'contact-form-7' ), $post );
|
233 |
+
$time = get_post_timestamp( $post );
|
|
|
|
|
|
|
|
|
234 |
$time_diff = time() - $time;
|
235 |
|
236 |
+
if ( $time and 0 < $time_diff and $time_diff < DAY_IN_SECONDS ) {
|
237 |
$h_time = sprintf(
|
238 |
+
/* translators: %s: Human-readable time difference since the creation of the contact form */
|
239 |
__( '%s ago', 'contact-form-7' ),
|
240 |
human_time_diff( $time )
|
241 |
);
|
242 |
} else {
|
243 |
+
$h_time = get_the_time( __( 'Y/m/d', 'contact-form-7' ), $post );
|
244 |
}
|
245 |
|
246 |
+
return sprintf( '<span title="%1$s">%2$s</span>',
|
247 |
+
esc_attr( $t_time ),
|
248 |
+
esc_html( $h_time )
|
249 |
);
|
250 |
}
|
251 |
}
|
includes/config-validator.php
CHANGED
@@ -578,7 +578,7 @@ class WPCF7_ConfigValidator {
|
|
578 |
}
|
579 |
}
|
580 |
|
581 |
-
$max = 25 *
|
582 |
|
583 |
if ( $max < $total_size ) {
|
584 |
$this->add_error( sprintf( '%s.attachments', $template ),
|
578 |
}
|
579 |
}
|
580 |
|
581 |
+
$max = 25 * MB_IN_BYTES; // 25 MB
|
582 |
|
583 |
if ( $max < $total_size ) {
|
584 |
$this->add_error( sprintf( '%s.attachments', $template ),
|
includes/contact-form.php
CHANGED
@@ -366,6 +366,9 @@ class WPCF7_ContactForm {
|
|
366 |
$submission = WPCF7_Submission::get_instance();
|
367 |
|
368 |
switch ( $submission->get_status() ) {
|
|
|
|
|
|
|
369 |
case 'validation_failed':
|
370 |
$class .= ' invalid';
|
371 |
break;
|
@@ -389,6 +392,8 @@ class WPCF7_ContactForm {
|
|
389 |
preg_replace( '/[^0-9a-z]+/i', '-', $submission->get_status() )
|
390 |
);
|
391 |
}
|
|
|
|
|
392 |
}
|
393 |
|
394 |
if ( $args['html_class'] ) {
|
@@ -452,6 +457,7 @@ class WPCF7_ContactForm {
|
|
452 |
'_wpcf7_locale' => $this->locale(),
|
453 |
'_wpcf7_unit_tag' => $this->unit_tag(),
|
454 |
'_wpcf7_container_post' => 0,
|
|
|
455 |
);
|
456 |
|
457 |
if ( in_the_loop() ) {
|
@@ -479,54 +485,23 @@ class WPCF7_ContactForm {
|
|
479 |
public function form_response_output() {
|
480 |
$status = 'init';
|
481 |
$class = 'wpcf7-response-output';
|
482 |
-
$role = '';
|
483 |
$content = '';
|
484 |
|
485 |
if ( $this->is_posted() ) { // Post response output for non-AJAX
|
486 |
-
$role = 'alert';
|
487 |
-
|
488 |
$submission = WPCF7_Submission::get_instance();
|
489 |
$status = $submission->get_status();
|
490 |
$content = $submission->get_response();
|
491 |
-
|
492 |
-
switch ( $status ) {
|
493 |
-
case 'validation_failed':
|
494 |
-
$class .= ' wpcf7-validation-errors';
|
495 |
-
break;
|
496 |
-
case 'acceptance_missing':
|
497 |
-
$class .= ' wpcf7-acceptance-missing';
|
498 |
-
break;
|
499 |
-
case 'spam':
|
500 |
-
$class .= ' wpcf7-spam-blocked';
|
501 |
-
break;
|
502 |
-
case 'aborted':
|
503 |
-
$class .= ' wpcf7-aborted';
|
504 |
-
break;
|
505 |
-
case 'mail_sent':
|
506 |
-
$class .= ' wpcf7-mail-sent-ok';
|
507 |
-
break;
|
508 |
-
case 'mail_failed':
|
509 |
-
$class .= ' wpcf7-mail-sent-ng';
|
510 |
-
break;
|
511 |
-
default:
|
512 |
-
$class .= sprintf( ' wpcf7-custom-%s',
|
513 |
-
preg_replace( '/[^0-9a-z]+/i', '-', $status )
|
514 |
-
);
|
515 |
-
}
|
516 |
-
} else {
|
517 |
-
$class .= ' wpcf7-display-none';
|
518 |
}
|
519 |
|
520 |
$atts = array(
|
521 |
'class' => trim( $class ),
|
522 |
-
'role' =>
|
523 |
'aria-hidden' => 'true',
|
524 |
);
|
525 |
|
526 |
-
$atts = wpcf7_format_atts( $atts );
|
527 |
-
|
528 |
$output = sprintf( '<div %1$s>%2$s</div>',
|
529 |
-
|
|
|
530 |
);
|
531 |
|
532 |
$output = apply_filters( 'wpcf7_form_response_output',
|
@@ -540,12 +515,9 @@ class WPCF7_ContactForm {
|
|
540 |
|
541 |
public function screen_reader_response() {
|
542 |
$class = 'screen-reader-response';
|
543 |
-
$role = '';
|
544 |
$content = '';
|
545 |
|
546 |
if ( $this->is_posted() ) { // Post response output for non-AJAX
|
547 |
-
$role = 'alert';
|
548 |
-
|
549 |
$submission = WPCF7_Submission::get_instance();
|
550 |
|
551 |
if ( $response = $submission->get_response() ) {
|
@@ -576,7 +548,7 @@ class WPCF7_ContactForm {
|
|
576 |
|
577 |
$atts = array(
|
578 |
'class' => trim( $class ),
|
579 |
-
'role' =>
|
580 |
'aria-live' => 'polite',
|
581 |
);
|
582 |
|
@@ -766,6 +738,18 @@ class WPCF7_ContactForm {
|
|
766 |
$result['invalid_fields'] = $submission->get_invalid_fields();
|
767 |
}
|
768 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
do_action( 'wpcf7_submit', $this, $result );
|
770 |
|
771 |
return $result;
|
@@ -794,6 +778,14 @@ class WPCF7_ContactForm {
|
|
794 |
|
795 |
/* Additional settings */
|
796 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
797 |
public function additional_setting( $name, $max = 1 ) {
|
798 |
$settings = (array) explode( "\n", $this->prop( 'additional_settings' ) );
|
799 |
|
@@ -818,15 +810,11 @@ class WPCF7_ContactForm {
|
|
818 |
}
|
819 |
|
820 |
public function is_true( $name ) {
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
}
|
827 |
-
}
|
828 |
-
|
829 |
-
return false;
|
830 |
}
|
831 |
|
832 |
public function in_demo_mode() {
|
366 |
$submission = WPCF7_Submission::get_instance();
|
367 |
|
368 |
switch ( $submission->get_status() ) {
|
369 |
+
case 'init':
|
370 |
+
$class .= ' init';
|
371 |
+
break;
|
372 |
case 'validation_failed':
|
373 |
$class .= ' invalid';
|
374 |
break;
|
392 |
preg_replace( '/[^0-9a-z]+/i', '-', $submission->get_status() )
|
393 |
);
|
394 |
}
|
395 |
+
} else {
|
396 |
+
$class .= ' init';
|
397 |
}
|
398 |
|
399 |
if ( $args['html_class'] ) {
|
457 |
'_wpcf7_locale' => $this->locale(),
|
458 |
'_wpcf7_unit_tag' => $this->unit_tag(),
|
459 |
'_wpcf7_container_post' => 0,
|
460 |
+
'_wpcf7_posted_data_hash' => '',
|
461 |
);
|
462 |
|
463 |
if ( in_the_loop() ) {
|
485 |
public function form_response_output() {
|
486 |
$status = 'init';
|
487 |
$class = 'wpcf7-response-output';
|
|
|
488 |
$content = '';
|
489 |
|
490 |
if ( $this->is_posted() ) { // Post response output for non-AJAX
|
|
|
|
|
491 |
$submission = WPCF7_Submission::get_instance();
|
492 |
$status = $submission->get_status();
|
493 |
$content = $submission->get_response();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
}
|
495 |
|
496 |
$atts = array(
|
497 |
'class' => trim( $class ),
|
498 |
+
'role' => 'alert',
|
499 |
'aria-hidden' => 'true',
|
500 |
);
|
501 |
|
|
|
|
|
502 |
$output = sprintf( '<div %1$s>%2$s</div>',
|
503 |
+
wpcf7_format_atts( $atts ),
|
504 |
+
esc_html( $content )
|
505 |
);
|
506 |
|
507 |
$output = apply_filters( 'wpcf7_form_response_output',
|
515 |
|
516 |
public function screen_reader_response() {
|
517 |
$class = 'screen-reader-response';
|
|
|
518 |
$content = '';
|
519 |
|
520 |
if ( $this->is_posted() ) { // Post response output for non-AJAX
|
|
|
|
|
521 |
$submission = WPCF7_Submission::get_instance();
|
522 |
|
523 |
if ( $response = $submission->get_response() ) {
|
548 |
|
549 |
$atts = array(
|
550 |
'class' => trim( $class ),
|
551 |
+
'role' => 'alert',
|
552 |
'aria-live' => 'polite',
|
553 |
);
|
554 |
|
738 |
$result['invalid_fields'] = $submission->get_invalid_fields();
|
739 |
}
|
740 |
|
741 |
+
switch ( $submission->get_status() ) {
|
742 |
+
case 'init':
|
743 |
+
case 'validation_failed':
|
744 |
+
case 'acceptance_missing':
|
745 |
+
case 'spam':
|
746 |
+
$result['posted_data_hash'] = '';
|
747 |
+
break;
|
748 |
+
default:
|
749 |
+
$result['posted_data_hash'] = $submission->get_posted_data_hash();
|
750 |
+
break;
|
751 |
+
}
|
752 |
+
|
753 |
do_action( 'wpcf7_submit', $this, $result );
|
754 |
|
755 |
return $result;
|
778 |
|
779 |
/* Additional settings */
|
780 |
|
781 |
+
public function pref( $name ) {
|
782 |
+
$settings = $this->additional_setting( $name );
|
783 |
+
|
784 |
+
if ( $settings ) {
|
785 |
+
return $settings[0];
|
786 |
+
}
|
787 |
+
}
|
788 |
+
|
789 |
public function additional_setting( $name, $max = 1 ) {
|
790 |
$settings = (array) explode( "\n", $this->prop( 'additional_settings' ) );
|
791 |
|
810 |
}
|
811 |
|
812 |
public function is_true( $name ) {
|
813 |
+
return in_array(
|
814 |
+
$this->pref( $name ),
|
815 |
+
array( 'on', 'true', '1' ),
|
816 |
+
true
|
817 |
+
);
|
|
|
|
|
|
|
|
|
818 |
}
|
819 |
|
820 |
public function in_demo_mode() {
|
includes/css/styles.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
position: absolute;
|
3 |
overflow: hidden;
|
4 |
clip: rect(1px, 1px, 1px, 1px);
|
@@ -9,42 +9,46 @@ div.wpcf7 .screen-reader-response {
|
|
9 |
border: 0;
|
10 |
}
|
11 |
|
12 |
-
|
13 |
margin: 2em 0.5em 1em;
|
14 |
padding: 0.2em 1em;
|
15 |
-
border: 2px solid #
|
16 |
}
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
border:
|
25 |
}
|
26 |
|
27 |
-
|
28 |
-
border:
|
29 |
}
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
border:
|
34 |
}
|
35 |
|
36 |
.wpcf7-form-control-wrap {
|
37 |
position: relative;
|
38 |
}
|
39 |
|
40 |
-
|
41 |
color: #f00;
|
42 |
font-size: 1em;
|
43 |
font-weight: normal;
|
44 |
display: block;
|
45 |
}
|
46 |
|
47 |
-
.use-floating-validation-tip
|
48 |
position: absolute;
|
49 |
top: 20%;
|
50 |
left: 20%;
|
@@ -64,10 +68,6 @@ span.wpcf7-list-item-label::after {
|
|
64 |
content: " ";
|
65 |
}
|
66 |
|
67 |
-
.wpcf7-display-none {
|
68 |
-
display: none;
|
69 |
-
}
|
70 |
-
|
71 |
div.wpcf7 .ajax-loader {
|
72 |
visibility: hidden;
|
73 |
display: inline-block;
|
1 |
+
.wpcf7 .screen-reader-response {
|
2 |
position: absolute;
|
3 |
overflow: hidden;
|
4 |
clip: rect(1px, 1px, 1px, 1px);
|
9 |
border: 0;
|
10 |
}
|
11 |
|
12 |
+
.wpcf7 form .wpcf7-response-output {
|
13 |
margin: 2em 0.5em 1em;
|
14 |
padding: 0.2em 1em;
|
15 |
+
border: 2px solid #00a0d2; /* Blue */
|
16 |
}
|
17 |
|
18 |
+
.wpcf7 form.init .wpcf7-response-output {
|
19 |
+
display: none;
|
20 |
+
}
|
21 |
+
|
22 |
+
.wpcf7 form.sent .wpcf7-response-output {
|
23 |
+
border-color: #46b450; /* Green */
|
24 |
}
|
25 |
|
26 |
+
.wpcf7 form.failed .wpcf7-response-output,
|
27 |
+
.wpcf7 form.aborted .wpcf7-response-output {
|
28 |
+
border-color: #dc3232; /* Red */
|
29 |
}
|
30 |
|
31 |
+
.wpcf7 form.spam .wpcf7-response-output {
|
32 |
+
border-color: #f56e28; /* Orange */
|
33 |
}
|
34 |
|
35 |
+
.wpcf7 form.invalid .wpcf7-response-output,
|
36 |
+
.wpcf7 form.unaccepted .wpcf7-response-output {
|
37 |
+
border-color: #ffb900; /* Yellow */
|
38 |
}
|
39 |
|
40 |
.wpcf7-form-control-wrap {
|
41 |
position: relative;
|
42 |
}
|
43 |
|
44 |
+
.wpcf7-not-valid-tip {
|
45 |
color: #f00;
|
46 |
font-size: 1em;
|
47 |
font-weight: normal;
|
48 |
display: block;
|
49 |
}
|
50 |
|
51 |
+
.use-floating-validation-tip .wpcf7-not-valid-tip {
|
52 |
position: absolute;
|
53 |
top: 20%;
|
54 |
left: 20%;
|
68 |
content: " ";
|
69 |
}
|
70 |
|
|
|
|
|
|
|
|
|
71 |
div.wpcf7 .ajax-loader {
|
72 |
visibility: hidden;
|
73 |
display: inline-block;
|
includes/form-tag.php
CHANGED
@@ -190,6 +190,7 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
190 |
}
|
191 |
|
192 |
if ( preg_match( '/^today(?:([+-][0-9]+)([a-z]*))?/', $option, $matches ) ) {
|
|
|
193 |
$number = isset( $matches[1] ) ? (int) $matches[1] : 0;
|
194 |
$unit = isset( $matches[2] ) ? $matches[2] : '';
|
195 |
|
@@ -197,11 +198,6 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
197 |
$unit = 'days';
|
198 |
}
|
199 |
|
200 |
-
// Temporary fix until introducing wp_date()
|
201 |
-
$today = gmdate( 'Y-m-d',
|
202 |
-
time() + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS
|
203 |
-
);
|
204 |
-
|
205 |
$format = sprintf( '%1$s %2$s %3$s', $today, $number, $unit );
|
206 |
|
207 |
return gmdate( 'Y-m-d', strtotime( $format ) );
|
@@ -327,7 +323,7 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
327 |
return apply_filters( 'wpcf7_form_tag_data_option', null, $options, $args );
|
328 |
}
|
329 |
|
330 |
-
public function get_limit_option( $default =
|
331 |
$pattern = '/^limit:([1-9][0-9]*)([kKmM]?[bB])?$/';
|
332 |
|
333 |
$matches = $this->get_first_match_option( $pattern );
|
@@ -339,9 +335,9 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
339 |
$kbmb = strtolower( $matches[2] );
|
340 |
|
341 |
if ( 'kb' == $kbmb ) {
|
342 |
-
$size *=
|
343 |
} elseif ( 'mb' == $kbmb ) {
|
344 |
-
$size *=
|
345 |
}
|
346 |
}
|
347 |
|
190 |
}
|
191 |
|
192 |
if ( preg_match( '/^today(?:([+-][0-9]+)([a-z]*))?/', $option, $matches ) ) {
|
193 |
+
$today = wp_date( 'Y-m-d' );
|
194 |
$number = isset( $matches[1] ) ? (int) $matches[1] : 0;
|
195 |
$unit = isset( $matches[2] ) ? $matches[2] : '';
|
196 |
|
198 |
$unit = 'days';
|
199 |
}
|
200 |
|
|
|
|
|
|
|
|
|
|
|
201 |
$format = sprintf( '%1$s %2$s %3$s', $today, $number, $unit );
|
202 |
|
203 |
return gmdate( 'Y-m-d', strtotime( $format ) );
|
323 |
return apply_filters( 'wpcf7_form_tag_data_option', null, $options, $args );
|
324 |
}
|
325 |
|
326 |
+
public function get_limit_option( $default = MB_IN_BYTES ) {
|
327 |
$pattern = '/^limit:([1-9][0-9]*)([kKmM]?[bB])?$/';
|
328 |
|
329 |
$matches = $this->get_first_match_option( $pattern );
|
335 |
$kbmb = strtolower( $matches[2] );
|
336 |
|
337 |
if ( 'kb' == $kbmb ) {
|
338 |
+
$size *= KB_IN_BYTES;
|
339 |
} elseif ( 'mb' == $kbmb ) {
|
340 |
+
$size *= MB_IN_BYTES;
|
341 |
}
|
342 |
}
|
343 |
|
includes/formatting.php
CHANGED
@@ -338,7 +338,7 @@ function wpcf7_is_email_in_site_domain( $email ) {
|
|
338 |
}
|
339 |
|
340 |
function wpcf7_antiscript_file_name( $filename ) {
|
341 |
-
$filename =
|
342 |
$parts = explode( '.', $filename );
|
343 |
|
344 |
if ( count( $parts ) < 2 ) {
|
338 |
}
|
339 |
|
340 |
function wpcf7_antiscript_file_name( $filename ) {
|
341 |
+
$filename = wp_basename( $filename );
|
342 |
$parts = explode( '.', $filename );
|
343 |
|
344 |
if ( count( $parts ) < 2 ) {
|
includes/functions.php
CHANGED
@@ -371,13 +371,42 @@ function wpcf7_deprecated_function( $function, $version, $replacement ) {
|
|
371 |
|
372 |
if ( WP_DEBUG and $trigger_error ) {
|
373 |
if ( function_exists( '__' ) ) {
|
374 |
-
trigger_error(
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
} else {
|
376 |
-
trigger_error(
|
|
|
|
|
|
|
|
|
|
|
377 |
}
|
378 |
}
|
379 |
}
|
380 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
function wpcf7_log_remote_request( $url, $request, $response ) {
|
382 |
$log = sprintf(
|
383 |
/* translators: 1: response code, 2: message, 3: body, 4: URL */
|
371 |
|
372 |
if ( WP_DEBUG and $trigger_error ) {
|
373 |
if ( function_exists( '__' ) ) {
|
374 |
+
trigger_error(
|
375 |
+
sprintf(
|
376 |
+
/* translators: 1: PHP function name, 2: version number, 3: alternative function name */
|
377 |
+
__( '%1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.', 'contact-form-7' ),
|
378 |
+
$function, $version, $replacement
|
379 |
+
)
|
380 |
+
);
|
381 |
} else {
|
382 |
+
trigger_error(
|
383 |
+
sprintf(
|
384 |
+
'%1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.',
|
385 |
+
$function, $version, $replacement
|
386 |
+
)
|
387 |
+
);
|
388 |
}
|
389 |
}
|
390 |
}
|
391 |
|
392 |
+
function wpcf7_apply_filters_deprecated( $tag, $args, $version, $replacement ) {
|
393 |
+
if ( ! has_filter( $tag ) ) {
|
394 |
+
return $args[0];
|
395 |
+
}
|
396 |
+
|
397 |
+
if ( WP_DEBUG and apply_filters( 'deprecated_hook_trigger_error', true ) ) {
|
398 |
+
trigger_error(
|
399 |
+
sprintf(
|
400 |
+
/* translators: 1: WordPress hook name, 2: version number, 3: alternative hook name */
|
401 |
+
__( '%1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.', 'contact-form-7' ),
|
402 |
+
$tag, $version, $replacement
|
403 |
+
)
|
404 |
+
);
|
405 |
+
}
|
406 |
+
|
407 |
+
return apply_filters_ref_array( $tag, $args );
|
408 |
+
}
|
409 |
+
|
410 |
function wpcf7_log_remote_request( $url, $request, $response ) {
|
411 |
$log = sprintf(
|
412 |
/* translators: 1: response code, 2: message, 3: body, 4: URL */
|
includes/js/scripts.js
CHANGED
@@ -45,6 +45,8 @@
|
|
45 |
wpcf7.initForm = function( form ) {
|
46 |
var $form = $( form );
|
47 |
|
|
|
|
|
48 |
$form.submit( function( event ) {
|
49 |
if ( ! wpcf7.supportHtml5.placeholder ) {
|
50 |
$( '[placeholder].placeheld', $form ).each( function( i, n ) {
|
@@ -161,7 +163,6 @@
|
|
161 |
var $form = $( form );
|
162 |
|
163 |
$( '.ajax-loader', $form ).addClass( 'is-active' );
|
164 |
-
|
165 |
wpcf7.clearResponse( $form );
|
166 |
|
167 |
var formData = new FormData( $form.get( 0 ) );
|
@@ -184,12 +185,6 @@
|
|
184 |
detail.unitTag = field.value;
|
185 |
} else if ( '_wpcf7_container_post' == field.name ) {
|
186 |
detail.containerPostId = field.value;
|
187 |
-
} else if ( field.name.match( /^_wpcf7_\w+_free_text_/ ) ) {
|
188 |
-
var owner = field.name.replace( /^_wpcf7_\w+_free_text_/, '' );
|
189 |
-
detail.inputs.push( {
|
190 |
-
name: owner + '-free-text',
|
191 |
-
value: field.value
|
192 |
-
} );
|
193 |
} else if ( field.name.match( /^_/ ) ) {
|
194 |
// do nothing
|
195 |
} else {
|
@@ -204,11 +199,12 @@
|
|
204 |
detail.status = data.status;
|
205 |
detail.apiResponse = data;
|
206 |
|
207 |
-
var $message = $( '.wpcf7-response-output', $form );
|
208 |
-
|
209 |
switch ( data.status ) {
|
|
|
|
|
|
|
210 |
case 'validation_failed':
|
211 |
-
$.each( data.
|
212 |
$( n.into, $form ).each( function() {
|
213 |
wpcf7.notValidTip( this, n.message );
|
214 |
$( '.wpcf7-form-control', this ).addClass( 'wpcf7-not-valid' );
|
@@ -216,46 +212,33 @@
|
|
216 |
} );
|
217 |
} );
|
218 |
|
219 |
-
|
220 |
-
$form.addClass( 'invalid' );
|
221 |
-
|
222 |
wpcf7.triggerEvent( data.into, 'invalid', detail );
|
223 |
break;
|
224 |
case 'acceptance_missing':
|
225 |
-
|
226 |
-
$form.addClass( 'unaccepted' );
|
227 |
-
|
228 |
wpcf7.triggerEvent( data.into, 'unaccepted', detail );
|
229 |
break;
|
230 |
case 'spam':
|
231 |
-
|
232 |
-
$form.addClass( 'spam' );
|
233 |
-
|
234 |
wpcf7.triggerEvent( data.into, 'spam', detail );
|
235 |
break;
|
236 |
case 'aborted':
|
237 |
-
|
238 |
-
$form.addClass( 'aborted' );
|
239 |
-
|
240 |
wpcf7.triggerEvent( data.into, 'aborted', detail );
|
241 |
break;
|
242 |
case 'mail_sent':
|
243 |
-
|
244 |
-
$form.addClass( 'sent' );
|
245 |
-
|
246 |
wpcf7.triggerEvent( data.into, 'mailsent', detail );
|
247 |
break;
|
248 |
case 'mail_failed':
|
249 |
-
|
250 |
-
$form.addClass( 'failed' );
|
251 |
-
|
252 |
wpcf7.triggerEvent( data.into, 'mailfailed', detail );
|
253 |
break;
|
254 |
default:
|
255 |
-
|
256 |
-
+ data.status.replace( /[^0-9a-z]+/i, '-' )
|
257 |
-
|
258 |
-
$form.addClass( customStatusClass );
|
259 |
}
|
260 |
|
261 |
wpcf7.refill( $form, data );
|
@@ -277,17 +260,17 @@
|
|
277 |
} );
|
278 |
}
|
279 |
|
280 |
-
$
|
281 |
-
|
282 |
|
283 |
$( '.screen-reader-response', $form.closest( '.wpcf7' ) ).each( function() {
|
284 |
var $response = $( this );
|
285 |
-
$response.html( '' ).
|
286 |
|
287 |
-
if ( data.
|
288 |
var $invalids = $( '<ul></ul>' );
|
289 |
|
290 |
-
$.each( data.
|
291 |
if ( n.idref ) {
|
292 |
var $li = $( '<li></li>' ).append( $( '<a></a>' ).attr( 'href', '#' + n.idref ).append( n.message ) );
|
293 |
} else {
|
@@ -300,8 +283,13 @@
|
|
300 |
$response.append( $invalids );
|
301 |
}
|
302 |
|
303 |
-
$response.
|
304 |
} );
|
|
|
|
|
|
|
|
|
|
|
305 |
};
|
306 |
|
307 |
$.ajax( {
|
@@ -322,21 +310,26 @@
|
|
322 |
};
|
323 |
|
324 |
wpcf7.triggerEvent = function( target, name, detail ) {
|
325 |
-
var $target = $( target );
|
326 |
-
|
327 |
-
/* DOM event */
|
328 |
var event = new CustomEvent( 'wpcf7' + name, {
|
329 |
bubbles: true,
|
330 |
detail: detail
|
331 |
} );
|
332 |
|
333 |
-
$target.get( 0 ).dispatchEvent( event );
|
334 |
-
|
335 |
-
/* jQuery event */
|
336 |
-
$target.trigger( 'wpcf7:' + name, detail );
|
337 |
-
$target.trigger( name + '.wpcf7', detail ); // deprecated
|
338 |
};
|
339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
wpcf7.toggleSubmit = function( form, state ) {
|
341 |
var $form = $( form );
|
342 |
var $submit = $( 'input:submit', $form );
|
@@ -492,16 +485,13 @@
|
|
492 |
|
493 |
wpcf7.clearResponse = function( form ) {
|
494 |
var $form = $( form );
|
495 |
-
$form.
|
496 |
-
$form.siblings( '.screen-reader-response' ).html( '' ).attr( 'role', '' );
|
497 |
|
498 |
$( '.wpcf7-not-valid-tip', $form ).remove();
|
499 |
$( '[aria-invalid]', $form ).attr( 'aria-invalid', 'false' );
|
500 |
$( '.wpcf7-form-control', $form ).removeClass( 'wpcf7-not-valid' );
|
501 |
|
502 |
-
$( '.wpcf7-response-output', $form )
|
503 |
-
.hide().empty().removeAttr( 'role' )
|
504 |
-
.removeClass( 'wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked' );
|
505 |
};
|
506 |
|
507 |
wpcf7.apiSettings.getRoute = function( path ) {
|
45 |
wpcf7.initForm = function( form ) {
|
46 |
var $form = $( form );
|
47 |
|
48 |
+
wpcf7.setStatus( $form, 'init' );
|
49 |
+
|
50 |
$form.submit( function( event ) {
|
51 |
if ( ! wpcf7.supportHtml5.placeholder ) {
|
52 |
$( '[placeholder].placeheld', $form ).each( function( i, n ) {
|
163 |
var $form = $( form );
|
164 |
|
165 |
$( '.ajax-loader', $form ).addClass( 'is-active' );
|
|
|
166 |
wpcf7.clearResponse( $form );
|
167 |
|
168 |
var formData = new FormData( $form.get( 0 ) );
|
185 |
detail.unitTag = field.value;
|
186 |
} else if ( '_wpcf7_container_post' == field.name ) {
|
187 |
detail.containerPostId = field.value;
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
} else if ( field.name.match( /^_/ ) ) {
|
189 |
// do nothing
|
190 |
} else {
|
199 |
detail.status = data.status;
|
200 |
detail.apiResponse = data;
|
201 |
|
|
|
|
|
202 |
switch ( data.status ) {
|
203 |
+
case 'init':
|
204 |
+
wpcf7.setStatus( $form, 'init' );
|
205 |
+
break;
|
206 |
case 'validation_failed':
|
207 |
+
$.each( data.invalid_fields, function( i, n ) {
|
208 |
$( n.into, $form ).each( function() {
|
209 |
wpcf7.notValidTip( this, n.message );
|
210 |
$( '.wpcf7-form-control', this ).addClass( 'wpcf7-not-valid' );
|
212 |
} );
|
213 |
} );
|
214 |
|
215 |
+
wpcf7.setStatus( $form, 'invalid' );
|
|
|
|
|
216 |
wpcf7.triggerEvent( data.into, 'invalid', detail );
|
217 |
break;
|
218 |
case 'acceptance_missing':
|
219 |
+
wpcf7.setStatus( $form, 'unaccepted' );
|
|
|
|
|
220 |
wpcf7.triggerEvent( data.into, 'unaccepted', detail );
|
221 |
break;
|
222 |
case 'spam':
|
223 |
+
wpcf7.setStatus( $form, 'spam' );
|
|
|
|
|
224 |
wpcf7.triggerEvent( data.into, 'spam', detail );
|
225 |
break;
|
226 |
case 'aborted':
|
227 |
+
wpcf7.setStatus( $form, 'aborted' );
|
|
|
|
|
228 |
wpcf7.triggerEvent( data.into, 'aborted', detail );
|
229 |
break;
|
230 |
case 'mail_sent':
|
231 |
+
wpcf7.setStatus( $form, 'sent' );
|
|
|
|
|
232 |
wpcf7.triggerEvent( data.into, 'mailsent', detail );
|
233 |
break;
|
234 |
case 'mail_failed':
|
235 |
+
wpcf7.setStatus( $form, 'failed' );
|
|
|
|
|
236 |
wpcf7.triggerEvent( data.into, 'mailfailed', detail );
|
237 |
break;
|
238 |
default:
|
239 |
+
wpcf7.setStatus( $form,
|
240 |
+
'custom-' + data.status.replace( /[^0-9a-z]+/i, '-' )
|
241 |
+
);
|
|
|
242 |
}
|
243 |
|
244 |
wpcf7.refill( $form, data );
|
260 |
} );
|
261 |
}
|
262 |
|
263 |
+
$( '.wpcf7-response-output', $form )
|
264 |
+
.html( '' ).append( data.message ).slideDown( 'fast' );
|
265 |
|
266 |
$( '.screen-reader-response', $form.closest( '.wpcf7' ) ).each( function() {
|
267 |
var $response = $( this );
|
268 |
+
$response.html( '' ).append( data.message );
|
269 |
|
270 |
+
if ( data.invalid_fields ) {
|
271 |
var $invalids = $( '<ul></ul>' );
|
272 |
|
273 |
+
$.each( data.invalid_fields, function( i, n ) {
|
274 |
if ( n.idref ) {
|
275 |
var $li = $( '<li></li>' ).append( $( '<a></a>' ).attr( 'href', '#' + n.idref ).append( n.message ) );
|
276 |
} else {
|
283 |
$response.append( $invalids );
|
284 |
}
|
285 |
|
286 |
+
$response.focus();
|
287 |
} );
|
288 |
+
|
289 |
+
if ( data.posted_data_hash ) {
|
290 |
+
$form.find( 'input[name="_wpcf7_posted_data_hash"]' ).first()
|
291 |
+
.val( data.posted_data_hash );
|
292 |
+
}
|
293 |
};
|
294 |
|
295 |
$.ajax( {
|
310 |
};
|
311 |
|
312 |
wpcf7.triggerEvent = function( target, name, detail ) {
|
|
|
|
|
|
|
313 |
var event = new CustomEvent( 'wpcf7' + name, {
|
314 |
bubbles: true,
|
315 |
detail: detail
|
316 |
} );
|
317 |
|
318 |
+
$( target ).get( 0 ).dispatchEvent( event );
|
|
|
|
|
|
|
|
|
319 |
};
|
320 |
|
321 |
+
wpcf7.setStatus = function( form, status ) {
|
322 |
+
var $form = $( form );
|
323 |
+
var prevStatus = $form.data( 'status' );
|
324 |
+
|
325 |
+
$form.data( 'status', status );
|
326 |
+
$form.addClass( status );
|
327 |
+
|
328 |
+
if ( prevStatus && prevStatus !== status ) {
|
329 |
+
$form.removeClass( prevStatus );
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
wpcf7.toggleSubmit = function( form, state ) {
|
334 |
var $form = $( form );
|
335 |
var $submit = $( 'input:submit', $form );
|
485 |
|
486 |
wpcf7.clearResponse = function( form ) {
|
487 |
var $form = $( form );
|
488 |
+
$form.siblings( '.screen-reader-response' ).html( '' );
|
|
|
489 |
|
490 |
$( '.wpcf7-not-valid-tip', $form ).remove();
|
491 |
$( '[aria-invalid]', $form ).attr( 'aria-invalid', 'false' );
|
492 |
$( '.wpcf7-form-control', $form ).removeClass( 'wpcf7-not-valid' );
|
493 |
|
494 |
+
$( '.wpcf7-response-output', $form ).hide().empty();
|
|
|
|
|
495 |
};
|
496 |
|
497 |
wpcf7.apiSettings.getRoute = function( path ) {
|
includes/mail.php
CHANGED
@@ -105,7 +105,8 @@ class WPCF7_Mail {
|
|
105 |
);
|
106 |
|
107 |
$components = apply_filters( 'wpcf7_mail_components',
|
108 |
-
$components, wpcf7_get_current_contact_form(), $this
|
|
|
109 |
|
110 |
if ( ! $send ) {
|
111 |
return $components;
|
@@ -340,11 +341,14 @@ class WPCF7_MailTaggedText {
|
|
340 |
|
341 |
$replaced = apply_filters(
|
342 |
"wpcf7_mail_tag_replaced_{$type}", $replaced,
|
343 |
-
$submitted, $html, $mail_tag
|
|
|
344 |
}
|
345 |
|
346 |
-
$replaced = apply_filters(
|
347 |
-
|
|
|
|
|
348 |
|
349 |
$replaced = wp_unslash( trim( $replaced ) );
|
350 |
|
@@ -369,7 +373,11 @@ class WPCF7_MailTaggedText {
|
|
369 |
|
370 |
foreach ( $original as $key => $value ) {
|
371 |
if ( preg_match( '/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value ) ) {
|
372 |
-
$
|
|
|
|
|
|
|
|
|
373 |
}
|
374 |
}
|
375 |
|
105 |
);
|
106 |
|
107 |
$components = apply_filters( 'wpcf7_mail_components',
|
108 |
+
$components, wpcf7_get_current_contact_form(), $this
|
109 |
+
);
|
110 |
|
111 |
if ( ! $send ) {
|
112 |
return $components;
|
341 |
|
342 |
$replaced = apply_filters(
|
343 |
"wpcf7_mail_tag_replaced_{$type}", $replaced,
|
344 |
+
$submitted, $html, $mail_tag
|
345 |
+
);
|
346 |
}
|
347 |
|
348 |
+
$replaced = apply_filters(
|
349 |
+
'wpcf7_mail_tag_replaced', $replaced,
|
350 |
+
$submitted, $html, $mail_tag
|
351 |
+
);
|
352 |
|
353 |
$replaced = wp_unslash( trim( $replaced ) );
|
354 |
|
373 |
|
374 |
foreach ( $original as $key => $value ) {
|
375 |
if ( preg_match( '/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value ) ) {
|
376 |
+
$datetime = date_create( $value, wp_timezone() );
|
377 |
+
|
378 |
+
if ( false !== $datetime ) {
|
379 |
+
$original[$key] = wp_date( $format, $datetime->getTimestamp() );
|
380 |
+
}
|
381 |
}
|
382 |
}
|
383 |
|
includes/pipe.php
CHANGED
@@ -75,4 +75,16 @@ class WPCF7_Pipes {
|
|
75 |
|
76 |
return $this->pipes[array_rand( $this->pipes )];
|
77 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
75 |
|
76 |
return $this->pipes[array_rand( $this->pipes )];
|
77 |
}
|
78 |
+
|
79 |
+
public function to_array() {
|
80 |
+
return array_map(
|
81 |
+
function( WPCF7_Pipe $pipe ) {
|
82 |
+
return array(
|
83 |
+
$pipe->before,
|
84 |
+
$pipe->after,
|
85 |
+
);
|
86 |
+
},
|
87 |
+
$this->pipes
|
88 |
+
);
|
89 |
+
}
|
90 |
}
|
includes/rest-api.php
CHANGED
@@ -62,7 +62,8 @@ function wpcf7_rest_get_contact_forms( WP_REST_Request $request ) {
|
|
62 |
if ( ! current_user_can( 'wpcf7_read_contact_forms' ) ) {
|
63 |
return new WP_Error( 'wpcf7_forbidden',
|
64 |
__( "You are not allowed to access contact forms.", 'contact-form-7' ),
|
65 |
-
array( 'status' => 403 )
|
|
|
66 |
}
|
67 |
|
68 |
$args = array();
|
@@ -119,13 +120,15 @@ function wpcf7_rest_create_contact_form( WP_REST_Request $request ) {
|
|
119 |
if ( $id ) {
|
120 |
return new WP_Error( 'wpcf7_post_exists',
|
121 |
__( "Cannot create existing contact form.", 'contact-form-7' ),
|
122 |
-
array( 'status' => 400 )
|
|
|
123 |
}
|
124 |
|
125 |
if ( ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
126 |
return new WP_Error( 'wpcf7_forbidden',
|
127 |
__( "You are not allowed to create a contact form.", 'contact-form-7' ),
|
128 |
-
array( 'status' => 403 )
|
|
|
129 |
}
|
130 |
|
131 |
$args = $request->get_params();
|
@@ -136,7 +139,8 @@ function wpcf7_rest_create_contact_form( WP_REST_Request $request ) {
|
|
136 |
if ( ! $item ) {
|
137 |
return new WP_Error( 'wpcf7_cannot_save',
|
138 |
__( "There was an error saving the contact form.", 'contact-form-7' ),
|
139 |
-
array( 'status' => 500 )
|
|
|
140 |
}
|
141 |
|
142 |
$response = array(
|
@@ -144,7 +148,7 @@ function wpcf7_rest_create_contact_form( WP_REST_Request $request ) {
|
|
144 |
'slug' => $item->name(),
|
145 |
'title' => $item->title(),
|
146 |
'locale' => $item->locale(),
|
147 |
-
'properties' => $item
|
148 |
'config_errors' => array(),
|
149 |
);
|
150 |
|
@@ -169,13 +173,15 @@ function wpcf7_rest_get_contact_form( WP_REST_Request $request ) {
|
|
169 |
if ( ! $item ) {
|
170 |
return new WP_Error( 'wpcf7_not_found',
|
171 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
172 |
-
array( 'status' => 404 )
|
|
|
173 |
}
|
174 |
|
175 |
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
|
176 |
return new WP_Error( 'wpcf7_forbidden',
|
177 |
__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
|
178 |
-
array( 'status' => 403 )
|
|
|
179 |
}
|
180 |
|
181 |
$response = array(
|
@@ -183,7 +189,7 @@ function wpcf7_rest_get_contact_form( WP_REST_Request $request ) {
|
|
183 |
'slug' => $item->name(),
|
184 |
'title' => $item->title(),
|
185 |
'locale' => $item->locale(),
|
186 |
-
'properties' => $item
|
187 |
);
|
188 |
|
189 |
return rest_ensure_response( $response );
|
@@ -196,13 +202,15 @@ function wpcf7_rest_update_contact_form( WP_REST_Request $request ) {
|
|
196 |
if ( ! $item ) {
|
197 |
return new WP_Error( 'wpcf7_not_found',
|
198 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
199 |
-
array( 'status' => 404 )
|
|
|
200 |
}
|
201 |
|
202 |
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
|
203 |
return new WP_Error( 'wpcf7_forbidden',
|
204 |
__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
|
205 |
-
array( 'status' => 403 )
|
|
|
206 |
}
|
207 |
|
208 |
$args = $request->get_params();
|
@@ -212,7 +220,8 @@ function wpcf7_rest_update_contact_form( WP_REST_Request $request ) {
|
|
212 |
if ( ! $item ) {
|
213 |
return new WP_Error( 'wpcf7_cannot_save',
|
214 |
__( "There was an error saving the contact form.", 'contact-form-7' ),
|
215 |
-
array( 'status' => 500 )
|
|
|
216 |
}
|
217 |
|
218 |
$response = array(
|
@@ -220,7 +229,7 @@ function wpcf7_rest_update_contact_form( WP_REST_Request $request ) {
|
|
220 |
'slug' => $item->name(),
|
221 |
'title' => $item->title(),
|
222 |
'locale' => $item->locale(),
|
223 |
-
'properties' => $item
|
224 |
'config_errors' => array(),
|
225 |
);
|
226 |
|
@@ -245,13 +254,15 @@ function wpcf7_rest_delete_contact_form( WP_REST_Request $request ) {
|
|
245 |
if ( ! $item ) {
|
246 |
return new WP_Error( 'wpcf7_not_found',
|
247 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
248 |
-
array( 'status' => 404 )
|
|
|
249 |
}
|
250 |
|
251 |
if ( ! current_user_can( 'wpcf7_delete_contact_form', $id ) ) {
|
252 |
return new WP_Error( 'wpcf7_forbidden',
|
253 |
__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
|
254 |
-
array( 'status' => 403 )
|
|
|
255 |
}
|
256 |
|
257 |
$result = $item->delete();
|
@@ -259,7 +270,8 @@ function wpcf7_rest_delete_contact_form( WP_REST_Request $request ) {
|
|
259 |
if ( ! $result ) {
|
260 |
return new WP_Error( 'wpcf7_cannot_delete',
|
261 |
__( "There was an error deleting the contact form.", 'contact-form-7' ),
|
262 |
-
array( 'status' => 500 )
|
|
|
263 |
}
|
264 |
|
265 |
$response = array( 'deleted' => true );
|
@@ -279,7 +291,8 @@ function wpcf7_rest_create_feedback( WP_REST_Request $request ) {
|
|
279 |
if ( ! $item ) {
|
280 |
return new WP_Error( 'wpcf7_not_found',
|
281 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
282 |
-
array( 'status' => 404 )
|
|
|
283 |
}
|
284 |
|
285 |
$result = $item->submit();
|
@@ -290,6 +303,7 @@ function wpcf7_rest_create_feedback( WP_REST_Request $request ) {
|
|
290 |
'into' => '#' . wpcf7_sanitize_unit_tag( $unit_tag ),
|
291 |
'status' => $result['status'],
|
292 |
'message' => $result['message'],
|
|
|
293 |
);
|
294 |
|
295 |
if ( 'validation_failed' == $result['status'] ) {
|
@@ -304,10 +318,17 @@ function wpcf7_rest_create_feedback( WP_REST_Request $request ) {
|
|
304 |
);
|
305 |
}
|
306 |
|
307 |
-
$response['
|
308 |
}
|
309 |
|
310 |
-
$response =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
|
312 |
return rest_ensure_response( $response );
|
313 |
}
|
@@ -319,10 +340,69 @@ function wpcf7_rest_get_refill( WP_REST_Request $request ) {
|
|
319 |
if ( ! $item ) {
|
320 |
return new WP_Error( 'wpcf7_not_found',
|
321 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
322 |
-
array( 'status' => 404 )
|
|
|
323 |
}
|
324 |
|
325 |
-
$response =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
|
327 |
return rest_ensure_response( $response );
|
328 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
if ( ! current_user_can( 'wpcf7_read_contact_forms' ) ) {
|
63 |
return new WP_Error( 'wpcf7_forbidden',
|
64 |
__( "You are not allowed to access contact forms.", 'contact-form-7' ),
|
65 |
+
array( 'status' => 403 )
|
66 |
+
);
|
67 |
}
|
68 |
|
69 |
$args = array();
|
120 |
if ( $id ) {
|
121 |
return new WP_Error( 'wpcf7_post_exists',
|
122 |
__( "Cannot create existing contact form.", 'contact-form-7' ),
|
123 |
+
array( 'status' => 400 )
|
124 |
+
);
|
125 |
}
|
126 |
|
127 |
if ( ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
128 |
return new WP_Error( 'wpcf7_forbidden',
|
129 |
__( "You are not allowed to create a contact form.", 'contact-form-7' ),
|
130 |
+
array( 'status' => 403 )
|
131 |
+
);
|
132 |
}
|
133 |
|
134 |
$args = $request->get_params();
|
139 |
if ( ! $item ) {
|
140 |
return new WP_Error( 'wpcf7_cannot_save',
|
141 |
__( "There was an error saving the contact form.", 'contact-form-7' ),
|
142 |
+
array( 'status' => 500 )
|
143 |
+
);
|
144 |
}
|
145 |
|
146 |
$response = array(
|
148 |
'slug' => $item->name(),
|
149 |
'title' => $item->title(),
|
150 |
'locale' => $item->locale(),
|
151 |
+
'properties' => wpcf7_get_properties_for_api( $item ),
|
152 |
'config_errors' => array(),
|
153 |
);
|
154 |
|
173 |
if ( ! $item ) {
|
174 |
return new WP_Error( 'wpcf7_not_found',
|
175 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
176 |
+
array( 'status' => 404 )
|
177 |
+
);
|
178 |
}
|
179 |
|
180 |
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
|
181 |
return new WP_Error( 'wpcf7_forbidden',
|
182 |
__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
|
183 |
+
array( 'status' => 403 )
|
184 |
+
);
|
185 |
}
|
186 |
|
187 |
$response = array(
|
189 |
'slug' => $item->name(),
|
190 |
'title' => $item->title(),
|
191 |
'locale' => $item->locale(),
|
192 |
+
'properties' => wpcf7_get_properties_for_api( $item ),
|
193 |
);
|
194 |
|
195 |
return rest_ensure_response( $response );
|
202 |
if ( ! $item ) {
|
203 |
return new WP_Error( 'wpcf7_not_found',
|
204 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
205 |
+
array( 'status' => 404 )
|
206 |
+
);
|
207 |
}
|
208 |
|
209 |
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
|
210 |
return new WP_Error( 'wpcf7_forbidden',
|
211 |
__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
|
212 |
+
array( 'status' => 403 )
|
213 |
+
);
|
214 |
}
|
215 |
|
216 |
$args = $request->get_params();
|
220 |
if ( ! $item ) {
|
221 |
return new WP_Error( 'wpcf7_cannot_save',
|
222 |
__( "There was an error saving the contact form.", 'contact-form-7' ),
|
223 |
+
array( 'status' => 500 )
|
224 |
+
);
|
225 |
}
|
226 |
|
227 |
$response = array(
|
229 |
'slug' => $item->name(),
|
230 |
'title' => $item->title(),
|
231 |
'locale' => $item->locale(),
|
232 |
+
'properties' => wpcf7_get_properties_for_api( $item ),
|
233 |
'config_errors' => array(),
|
234 |
);
|
235 |
|
254 |
if ( ! $item ) {
|
255 |
return new WP_Error( 'wpcf7_not_found',
|
256 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
257 |
+
array( 'status' => 404 )
|
258 |
+
);
|
259 |
}
|
260 |
|
261 |
if ( ! current_user_can( 'wpcf7_delete_contact_form', $id ) ) {
|
262 |
return new WP_Error( 'wpcf7_forbidden',
|
263 |
__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
|
264 |
+
array( 'status' => 403 )
|
265 |
+
);
|
266 |
}
|
267 |
|
268 |
$result = $item->delete();
|
270 |
if ( ! $result ) {
|
271 |
return new WP_Error( 'wpcf7_cannot_delete',
|
272 |
__( "There was an error deleting the contact form.", 'contact-form-7' ),
|
273 |
+
array( 'status' => 500 )
|
274 |
+
);
|
275 |
}
|
276 |
|
277 |
$response = array( 'deleted' => true );
|
291 |
if ( ! $item ) {
|
292 |
return new WP_Error( 'wpcf7_not_found',
|
293 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
294 |
+
array( 'status' => 404 )
|
295 |
+
);
|
296 |
}
|
297 |
|
298 |
$result = $item->submit();
|
303 |
'into' => '#' . wpcf7_sanitize_unit_tag( $unit_tag ),
|
304 |
'status' => $result['status'],
|
305 |
'message' => $result['message'],
|
306 |
+
'posted_data_hash' => $result['posted_data_hash'],
|
307 |
);
|
308 |
|
309 |
if ( 'validation_failed' == $result['status'] ) {
|
318 |
);
|
319 |
}
|
320 |
|
321 |
+
$response['invalid_fields'] = $invalid_fields;
|
322 |
}
|
323 |
|
324 |
+
$response = wpcf7_apply_filters_deprecated(
|
325 |
+
'wpcf7_ajax_json_echo',
|
326 |
+
array( $response, $result ),
|
327 |
+
'5.2',
|
328 |
+
'wpcf7_feedback_response'
|
329 |
+
);
|
330 |
+
|
331 |
+
$response = apply_filters( 'wpcf7_feedback_response', $response, $result );
|
332 |
|
333 |
return rest_ensure_response( $response );
|
334 |
}
|
340 |
if ( ! $item ) {
|
341 |
return new WP_Error( 'wpcf7_not_found',
|
342 |
__( "The requested contact form was not found.", 'contact-form-7' ),
|
343 |
+
array( 'status' => 404 )
|
344 |
+
);
|
345 |
}
|
346 |
|
347 |
+
$response = wpcf7_apply_filters_deprecated(
|
348 |
+
'wpcf7_ajax_onload',
|
349 |
+
array( array() ),
|
350 |
+
'5.2',
|
351 |
+
'wpcf7_refill_response'
|
352 |
+
);
|
353 |
+
|
354 |
+
$response = apply_filters( 'wpcf7_refill_response', array() );
|
355 |
|
356 |
return rest_ensure_response( $response );
|
357 |
}
|
358 |
+
|
359 |
+
function wpcf7_get_properties_for_api( WPCF7_ContactForm $contact_form ) {
|
360 |
+
$properties = $contact_form->get_properties();
|
361 |
+
|
362 |
+
$properties['form'] = array(
|
363 |
+
'content' => (string) $properties['form'],
|
364 |
+
'fields' => array_map(
|
365 |
+
function( WPCF7_FormTag $form_tag ) {
|
366 |
+
return array(
|
367 |
+
'type' => $form_tag->type,
|
368 |
+
'basetype' => $form_tag->basetype,
|
369 |
+
'name' => $form_tag->name,
|
370 |
+
'options' => $form_tag->options,
|
371 |
+
'raw_values' => $form_tag->raw_values,
|
372 |
+
'labels' => $form_tag->labels,
|
373 |
+
'values' => $form_tag->values,
|
374 |
+
'pipes' => $form_tag->pipes->to_array(),
|
375 |
+
'content' => $form_tag->content,
|
376 |
+
);
|
377 |
+
},
|
378 |
+
$contact_form->scan_form_tags()
|
379 |
+
),
|
380 |
+
);
|
381 |
+
|
382 |
+
$properties['additional_settings'] = array(
|
383 |
+
'content' => (string) $properties['additional_settings'],
|
384 |
+
'settings' => array_filter( array_map(
|
385 |
+
function( $setting ) {
|
386 |
+
$pattern = '/^([a-zA-Z0-9_]+)[\t ]*:(.*)$/';
|
387 |
+
|
388 |
+
if ( preg_match( $pattern, $setting, $matches ) ) {
|
389 |
+
$name = trim( $matches[1] );
|
390 |
+
$value = trim( $matches[2] );
|
391 |
+
|
392 |
+
if ( in_array( $value, array( 'on', 'true' ), true ) ) {
|
393 |
+
$value = true;
|
394 |
+
} elseif ( in_array( $value, array( 'off', 'false' ), true ) ) {
|
395 |
+
$value = false;
|
396 |
+
}
|
397 |
+
|
398 |
+
return array( $name, $value );
|
399 |
+
}
|
400 |
+
|
401 |
+
return false;
|
402 |
+
},
|
403 |
+
explode( "\n", $properties['additional_settings'] )
|
404 |
+
) ),
|
405 |
+
);
|
406 |
+
|
407 |
+
return $properties;
|
408 |
+
}
|
includes/special-mail-tags.php
CHANGED
@@ -42,16 +42,12 @@ function wpcf7_special_mail_tag( $output, $name, $html ) {
|
|
42 |
if ( '_date' == $name
|
43 |
or '_time' == $name ) {
|
44 |
if ( $timestamp = $submission->get_meta( 'timestamp' ) ) {
|
45 |
-
|
46 |
-
// Temporary fix until introducing wp_date()
|
47 |
-
$timestamp += get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
|
48 |
-
|
49 |
if ( '_date' == $name ) {
|
50 |
-
return
|
51 |
}
|
52 |
|
53 |
if ( '_time' == $name ) {
|
54 |
-
return
|
55 |
}
|
56 |
}
|
57 |
|
42 |
if ( '_date' == $name
|
43 |
or '_time' == $name ) {
|
44 |
if ( $timestamp = $submission->get_meta( 'timestamp' ) ) {
|
|
|
|
|
|
|
|
|
45 |
if ( '_date' == $name ) {
|
46 |
+
return wp_date( get_option( 'date_format' ), $timestamp );
|
47 |
}
|
48 |
|
49 |
if ( '_time' == $name ) {
|
50 |
+
return wp_date( get_option( 'time_format' ), $timestamp );
|
51 |
}
|
52 |
}
|
53 |
|
includes/submission.php
CHANGED
@@ -7,6 +7,8 @@ class WPCF7_Submission {
|
|
7 |
private $contact_form;
|
8 |
private $status = 'init';
|
9 |
private $posted_data = array();
|
|
|
|
|
10 |
private $uploaded_files = array();
|
11 |
private $skip_mail = false;
|
12 |
private $response = '';
|
@@ -15,32 +17,85 @@ class WPCF7_Submission {
|
|
15 |
private $consent = array();
|
16 |
private $spam_log = array();
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
$args = wp_parse_args( $args, array(
|
22 |
'skip_mail' => false,
|
23 |
) );
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
}
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
37 |
}
|
38 |
|
39 |
-
|
40 |
-
|
|
|
|
|
41 |
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
public function get_status() {
|
@@ -85,6 +140,50 @@ class WPCF7_Submission {
|
|
85 |
return $this->invalid_fields;
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
public function get_posted_data( $name = '' ) {
|
89 |
if ( ! empty( $name ) ) {
|
90 |
if ( isset( $this->posted_data[$name] ) ) {
|
@@ -98,8 +197,11 @@ class WPCF7_Submission {
|
|
98 |
}
|
99 |
|
100 |
private function setup_posted_data() {
|
101 |
-
$posted_data = (array) $_POST
|
102 |
-
|
|
|
|
|
|
|
103 |
$posted_data = $this->sanitize_posted_data( $posted_data );
|
104 |
|
105 |
$tags = $this->contact_form->scan_form_tags();
|
@@ -113,6 +215,11 @@ class WPCF7_Submission {
|
|
113 |
$name = $tag->name;
|
114 |
$pipes = $tag->pipes;
|
115 |
|
|
|
|
|
|
|
|
|
|
|
116 |
$value_orig = $value = '';
|
117 |
|
118 |
if ( isset( $posted_data[$name] ) ) {
|
@@ -126,13 +233,38 @@ class WPCF7_Submission {
|
|
126 |
$value = array();
|
127 |
|
128 |
foreach ( $value_orig as $v ) {
|
129 |
-
$value[] = $pipes->do_pipe(
|
130 |
}
|
131 |
} else {
|
132 |
-
$value = $pipes->do_pipe(
|
133 |
}
|
134 |
}
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
$value = apply_filters( "wpcf7_posted_data_{$type}", $value,
|
137 |
$value_orig, $tag );
|
138 |
|
@@ -146,6 +278,18 @@ class WPCF7_Submission {
|
|
146 |
|
147 |
$this->posted_data = apply_filters( 'wpcf7_posted_data', $posted_data );
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
return $this->posted_data;
|
150 |
}
|
151 |
|
@@ -160,69 +304,8 @@ class WPCF7_Submission {
|
|
160 |
return $value;
|
161 |
}
|
162 |
|
163 |
-
|
164 |
-
|
165 |
-
return $this->status;
|
166 |
-
}
|
167 |
-
|
168 |
-
$this->meta = array_merge( $this->meta, array(
|
169 |
-
'remote_ip' => $this->get_remote_ip_addr(),
|
170 |
-
'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] )
|
171 |
-
? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '',
|
172 |
-
'url' => $this->get_request_url(),
|
173 |
-
'timestamp' => time(),
|
174 |
-
'unit_tag' =>
|
175 |
-
isset( $_POST['_wpcf7_unit_tag'] ) ? $_POST['_wpcf7_unit_tag'] : '',
|
176 |
-
'container_post_id' => isset( $_POST['_wpcf7_container_post'] )
|
177 |
-
? (int) $_POST['_wpcf7_container_post'] : 0,
|
178 |
-
'current_user_id' => get_current_user_id(),
|
179 |
-
) );
|
180 |
-
|
181 |
-
$contact_form = $this->contact_form;
|
182 |
-
|
183 |
-
if ( $contact_form->is_true( 'do_not_store' ) ) {
|
184 |
-
$this->meta['do_not_store'] = true;
|
185 |
-
}
|
186 |
-
|
187 |
-
if ( ! $this->validate() ) { // Validation error occured
|
188 |
-
$this->set_status( 'validation_failed' );
|
189 |
-
$this->set_response( $contact_form->message( 'validation_error' ) );
|
190 |
-
|
191 |
-
} elseif ( ! $this->accepted() ) { // Not accepted terms
|
192 |
-
$this->set_status( 'acceptance_missing' );
|
193 |
-
$this->set_response( $contact_form->message( 'accept_terms' ) );
|
194 |
-
|
195 |
-
} elseif ( $this->spam() ) { // Spam!
|
196 |
-
$this->set_status( 'spam' );
|
197 |
-
$this->set_response( $contact_form->message( 'spam' ) );
|
198 |
-
|
199 |
-
} elseif ( ! $this->before_send_mail() ) {
|
200 |
-
if ( 'init' == $this->get_status() ) {
|
201 |
-
$this->set_status( 'aborted' );
|
202 |
-
}
|
203 |
-
|
204 |
-
if ( '' === $this->get_response() ) {
|
205 |
-
$this->set_response( $contact_form->filter_message(
|
206 |
-
__( "Sending mail has been aborted.", 'contact-form-7' ) )
|
207 |
-
);
|
208 |
-
}
|
209 |
-
|
210 |
-
} elseif ( $this->mail() ) {
|
211 |
-
$this->set_status( 'mail_sent' );
|
212 |
-
$this->set_response( $contact_form->message( 'mail_sent_ok' ) );
|
213 |
-
|
214 |
-
do_action( 'wpcf7_mail_sent', $contact_form );
|
215 |
-
|
216 |
-
} else {
|
217 |
-
$this->set_status( 'mail_failed' );
|
218 |
-
$this->set_response( $contact_form->message( 'mail_sent_ng' ) );
|
219 |
-
|
220 |
-
do_action( 'wpcf7_mail_failed', $contact_form );
|
221 |
-
}
|
222 |
-
|
223 |
-
$this->remove_uploaded_files();
|
224 |
-
|
225 |
-
return $this->status;
|
226 |
}
|
227 |
|
228 |
private function get_remote_ip_addr() {
|
@@ -293,6 +376,15 @@ class WPCF7_Submission {
|
|
293 |
private function spam() {
|
294 |
$spam = false;
|
295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
if ( $this->contact_form->is_true( 'subscribers_only' )
|
297 |
and current_user_can( 'wpcf7_submit', $this->contact_form->id() ) ) {
|
298 |
return $spam;
|
@@ -379,7 +471,8 @@ class WPCF7_Submission {
|
|
379 |
$contact_form = $this->contact_form;
|
380 |
|
381 |
$skip_mail = apply_filters( 'wpcf7_skip_mail',
|
382 |
-
$this->skip_mail, $contact_form
|
|
|
383 |
|
384 |
if ( $skip_mail ) {
|
385 |
return true;
|
@@ -396,7 +489,8 @@ class WPCF7_Submission {
|
|
396 |
}
|
397 |
|
398 |
$additional_mail = apply_filters( 'wpcf7_additional_mail',
|
399 |
-
$additional_mail, $contact_form
|
|
|
400 |
|
401 |
foreach ( $additional_mail as $name => $template ) {
|
402 |
WPCF7_Mail::send( $template, $name );
|
@@ -413,10 +507,18 @@ class WPCF7_Submission {
|
|
413 |
}
|
414 |
|
415 |
public function add_uploaded_file( $name, $file_path ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
$this->uploaded_files[$name] = $file_path;
|
417 |
|
418 |
if ( empty( $this->posted_data[$name] ) ) {
|
419 |
-
$this->posted_data[$name] =
|
420 |
}
|
421 |
}
|
422 |
|
@@ -432,10 +534,4 @@ class WPCF7_Submission {
|
|
432 |
}
|
433 |
}
|
434 |
}
|
435 |
-
|
436 |
-
public function get_meta( $name ) {
|
437 |
-
if ( isset( $this->meta[$name] ) ) {
|
438 |
-
return $this->meta[$name];
|
439 |
-
}
|
440 |
-
}
|
441 |
}
|
7 |
private $contact_form;
|
8 |
private $status = 'init';
|
9 |
private $posted_data = array();
|
10 |
+
private $posted_data_hash = null;
|
11 |
+
private $skip_spam_check = false;
|
12 |
private $uploaded_files = array();
|
13 |
private $skip_mail = false;
|
14 |
private $response = '';
|
17 |
private $consent = array();
|
18 |
private $spam_log = array();
|
19 |
|
20 |
+
public static function get_instance( $contact_form = null, $args = '' ) {
|
21 |
+
if ( $contact_form instanceof WPCF7_ContactForm ) {
|
22 |
+
if ( empty( self::$instance ) ) {
|
23 |
+
self::$instance = new self( $contact_form, $args );
|
24 |
+
self::$instance->proceed();
|
25 |
+
return self::$instance;
|
26 |
+
} else {
|
27 |
+
return null;
|
28 |
+
}
|
29 |
+
} else {
|
30 |
+
if ( empty( self::$instance ) ) {
|
31 |
+
return null;
|
32 |
+
} else {
|
33 |
+
return self::$instance;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
public static function is_restful() {
|
39 |
+
return defined( 'REST_REQUEST' ) && REST_REQUEST;
|
40 |
+
}
|
41 |
|
42 |
+
private function __construct( WPCF7_ContactForm $contact_form, $args = '' ) {
|
43 |
$args = wp_parse_args( $args, array(
|
44 |
'skip_mail' => false,
|
45 |
) );
|
46 |
|
47 |
+
$this->contact_form = $contact_form;
|
48 |
+
$this->skip_mail = (bool) $args['skip_mail'];
|
49 |
+
}
|
|
|
50 |
|
51 |
+
private function proceed() {
|
52 |
+
$this->setup_meta_data();
|
53 |
+
$this->setup_posted_data();
|
54 |
+
|
55 |
+
$contact_form = $this->contact_form;
|
56 |
+
|
57 |
+
if ( $this->is( 'init' ) and ! $this->validate() ) {
|
58 |
+
$this->set_status( 'validation_failed' );
|
59 |
+
$this->set_response( $contact_form->message( 'validation_error' ) );
|
60 |
}
|
61 |
|
62 |
+
if ( $this->is( 'init' ) and ! $this->accepted() ) {
|
63 |
+
$this->set_status( 'acceptance_missing' );
|
64 |
+
$this->set_response( $contact_form->message( 'accept_terms' ) );
|
65 |
+
}
|
66 |
|
67 |
+
if ( $this->is( 'init' ) and $this->spam() ) {
|
68 |
+
$this->set_status( 'spam' );
|
69 |
+
$this->set_response( $contact_form->message( 'spam' ) );
|
70 |
+
}
|
71 |
+
|
72 |
+
if ( $this->is( 'init' ) ) {
|
73 |
+
$abort = ! $this->before_send_mail();
|
74 |
+
|
75 |
+
if ( $abort ) {
|
76 |
+
if ( $this->is( 'init' ) ) {
|
77 |
+
$this->set_status( 'aborted' );
|
78 |
+
}
|
79 |
+
|
80 |
+
if ( '' === $this->get_response() ) {
|
81 |
+
$this->set_response( $contact_form->filter_message(
|
82 |
+
__( "Sending mail has been aborted.", 'contact-form-7' ) )
|
83 |
+
);
|
84 |
+
}
|
85 |
+
} elseif ( $this->mail() ) {
|
86 |
+
$this->set_status( 'mail_sent' );
|
87 |
+
$this->set_response( $contact_form->message( 'mail_sent_ok' ) );
|
88 |
+
|
89 |
+
do_action( 'wpcf7_mail_sent', $contact_form );
|
90 |
+
} else {
|
91 |
+
$this->set_status( 'mail_failed' );
|
92 |
+
$this->set_response( $contact_form->message( 'mail_sent_ng' ) );
|
93 |
+
|
94 |
+
do_action( 'wpcf7_mail_failed', $contact_form );
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
$this->remove_uploaded_files();
|
99 |
}
|
100 |
|
101 |
public function get_status() {
|
140 |
return $this->invalid_fields;
|
141 |
}
|
142 |
|
143 |
+
public function get_meta( $name ) {
|
144 |
+
if ( isset( $this->meta[$name] ) ) {
|
145 |
+
return $this->meta[$name];
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
private function setup_meta_data() {
|
150 |
+
$timestamp = time();
|
151 |
+
|
152 |
+
$remote_ip = $this->get_remote_ip_addr();
|
153 |
+
|
154 |
+
$remote_port = isset( $_SERVER['REMOTE_PORT'] )
|
155 |
+
? (int) $_SERVER['REMOTE_PORT'] : '';
|
156 |
+
|
157 |
+
$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] )
|
158 |
+
? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '';
|
159 |
+
|
160 |
+
$url = $this->get_request_url();
|
161 |
+
|
162 |
+
$unit_tag = isset( $_POST['_wpcf7_unit_tag'] )
|
163 |
+
? $_POST['_wpcf7_unit_tag'] : '';
|
164 |
+
|
165 |
+
$container_post_id = isset( $_POST['_wpcf7_container_post'] )
|
166 |
+
? (int) $_POST['_wpcf7_container_post'] : 0;
|
167 |
+
|
168 |
+
$current_user_id = get_current_user_id();
|
169 |
+
|
170 |
+
$do_not_store = $this->contact_form->is_true( 'do_not_store' );
|
171 |
+
|
172 |
+
$this->meta = array(
|
173 |
+
'timestamp' => $timestamp,
|
174 |
+
'remote_ip' => $remote_ip,
|
175 |
+
'remote_port' => $remote_port,
|
176 |
+
'user_agent' => $user_agent,
|
177 |
+
'url' => $url,
|
178 |
+
'unit_tag' => $unit_tag,
|
179 |
+
'container_post_id' => $container_post_id,
|
180 |
+
'current_user_id' => $current_user_id,
|
181 |
+
'do_not_store' => $do_not_store,
|
182 |
+
);
|
183 |
+
|
184 |
+
return $this->meta;
|
185 |
+
}
|
186 |
+
|
187 |
public function get_posted_data( $name = '' ) {
|
188 |
if ( ! empty( $name ) ) {
|
189 |
if ( isset( $this->posted_data[$name] ) ) {
|
197 |
}
|
198 |
|
199 |
private function setup_posted_data() {
|
200 |
+
$posted_data = array_filter( (array) $_POST, function( $key ) {
|
201 |
+
return '_' !== substr( $key, 0, 1 );
|
202 |
+
}, ARRAY_FILTER_USE_KEY );
|
203 |
+
|
204 |
+
$posted_data = wp_unslash( $posted_data );
|
205 |
$posted_data = $this->sanitize_posted_data( $posted_data );
|
206 |
|
207 |
$tags = $this->contact_form->scan_form_tags();
|
215 |
$name = $tag->name;
|
216 |
$pipes = $tag->pipes;
|
217 |
|
218 |
+
if ( wpcf7_form_tag_supports( $type, 'do-not-store' ) ) {
|
219 |
+
unset( $posted_data[$name] );
|
220 |
+
continue;
|
221 |
+
}
|
222 |
+
|
223 |
$value_orig = $value = '';
|
224 |
|
225 |
if ( isset( $posted_data[$name] ) ) {
|
233 |
$value = array();
|
234 |
|
235 |
foreach ( $value_orig as $v ) {
|
236 |
+
$value[] = $pipes->do_pipe( $v );
|
237 |
}
|
238 |
} else {
|
239 |
+
$value = $pipes->do_pipe( $value_orig );
|
240 |
}
|
241 |
}
|
242 |
|
243 |
+
if ( wpcf7_form_tag_supports( $type, 'selectable-values' )
|
244 |
+
and $tag->has_option( 'free_text' )
|
245 |
+
and isset( $posted_data[$name . '_free_text'] )
|
246 |
+
and is_array( $value ) ) {
|
247 |
+
$last_val = array_pop( $value );
|
248 |
+
|
249 |
+
list( $tied_item ) = array_slice(
|
250 |
+
WPCF7_USE_PIPE ? $tag->pipes->collect_afters() : $tag->values,
|
251 |
+
-1, 1
|
252 |
+
);
|
253 |
+
|
254 |
+
$tied_item = html_entity_decode( $tied_item, ENT_QUOTES, 'UTF-8' );
|
255 |
+
|
256 |
+
if ( $last_val === $tied_item ) {
|
257 |
+
$value[] = sprintf( '%s %s',
|
258 |
+
$last_val,
|
259 |
+
$posted_data[$name . '_free_text']
|
260 |
+
);
|
261 |
+
} else {
|
262 |
+
$value[] = $last_val;
|
263 |
+
}
|
264 |
+
|
265 |
+
unset( $posted_data[$name . '_free_text'] );
|
266 |
+
}
|
267 |
+
|
268 |
$value = apply_filters( "wpcf7_posted_data_{$type}", $value,
|
269 |
$value_orig, $tag );
|
270 |
|
278 |
|
279 |
$this->posted_data = apply_filters( 'wpcf7_posted_data', $posted_data );
|
280 |
|
281 |
+
$this->posted_data_hash = wp_hash(
|
282 |
+
wpcf7_flat_join( array_merge(
|
283 |
+
array(
|
284 |
+
$this->get_meta( 'remote_ip' ),
|
285 |
+
$this->get_meta( 'remote_port' ),
|
286 |
+
$this->get_meta( 'unit_tag' ),
|
287 |
+
),
|
288 |
+
$this->posted_data
|
289 |
+
) ),
|
290 |
+
'wpcf7_submission'
|
291 |
+
);
|
292 |
+
|
293 |
return $this->posted_data;
|
294 |
}
|
295 |
|
304 |
return $value;
|
305 |
}
|
306 |
|
307 |
+
public function get_posted_data_hash() {
|
308 |
+
return $this->posted_data_hash;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
}
|
310 |
|
311 |
private function get_remote_ip_addr() {
|
376 |
private function spam() {
|
377 |
$spam = false;
|
378 |
|
379 |
+
$skip_spam_check = apply_filters( 'wpcf7_skip_spam_check',
|
380 |
+
$this->skip_spam_check,
|
381 |
+
$this
|
382 |
+
);
|
383 |
+
|
384 |
+
if ( $skip_spam_check ) {
|
385 |
+
return $spam;
|
386 |
+
}
|
387 |
+
|
388 |
if ( $this->contact_form->is_true( 'subscribers_only' )
|
389 |
and current_user_can( 'wpcf7_submit', $this->contact_form->id() ) ) {
|
390 |
return $spam;
|
471 |
$contact_form = $this->contact_form;
|
472 |
|
473 |
$skip_mail = apply_filters( 'wpcf7_skip_mail',
|
474 |
+
$this->skip_mail, $contact_form
|
475 |
+
);
|
476 |
|
477 |
if ( $skip_mail ) {
|
478 |
return true;
|
489 |
}
|
490 |
|
491 |
$additional_mail = apply_filters( 'wpcf7_additional_mail',
|
492 |
+
$additional_mail, $contact_form
|
493 |
+
);
|
494 |
|
495 |
foreach ( $additional_mail as $name => $template ) {
|
496 |
WPCF7_Mail::send( $template, $name );
|
507 |
}
|
508 |
|
509 |
public function add_uploaded_file( $name, $file_path ) {
|
510 |
+
if ( ! wpcf7_is_name( $name ) ) {
|
511 |
+
return false;
|
512 |
+
}
|
513 |
+
|
514 |
+
if ( ! @is_file( $file_path ) or ! @is_readable( $file_path ) ) {
|
515 |
+
return false;
|
516 |
+
}
|
517 |
+
|
518 |
$this->uploaded_files[$name] = $file_path;
|
519 |
|
520 |
if ( empty( $this->posted_data[$name] ) ) {
|
521 |
+
$this->posted_data[$name] = md5_file( $file_path );
|
522 |
}
|
523 |
}
|
524 |
|
534 |
}
|
535 |
}
|
536 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
}
|
modules/checkbox.php
CHANGED
@@ -141,9 +141,7 @@ function wpcf7_checkbox_form_tag_handler( $tag ) {
|
|
141 |
$class .= ' last';
|
142 |
|
143 |
if ( $free_text ) {
|
144 |
-
$free_text_name =
|
145 |
-
'_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name
|
146 |
-
);
|
147 |
|
148 |
$free_text_atts = array(
|
149 |
'name' => $free_text_name,
|
@@ -202,58 +200,6 @@ function wpcf7_checkbox_validation_filter( $result, $tag ) {
|
|
202 |
}
|
203 |
|
204 |
|
205 |
-
/* Adding free text field */
|
206 |
-
|
207 |
-
add_filter( 'wpcf7_posted_data', 'wpcf7_checkbox_posted_data', 10, 1 );
|
208 |
-
|
209 |
-
function wpcf7_checkbox_posted_data( $posted_data ) {
|
210 |
-
$tags = wpcf7_scan_form_tags(
|
211 |
-
array( 'type' => array( 'checkbox', 'checkbox*', 'radio' ) ) );
|
212 |
-
|
213 |
-
if ( empty( $tags ) ) {
|
214 |
-
return $posted_data;
|
215 |
-
}
|
216 |
-
|
217 |
-
foreach ( $tags as $tag ) {
|
218 |
-
if ( ! isset( $posted_data[$tag->name] ) ) {
|
219 |
-
continue;
|
220 |
-
}
|
221 |
-
|
222 |
-
$posted_items = (array) $posted_data[$tag->name];
|
223 |
-
|
224 |
-
if ( $tag->has_option( 'free_text' ) ) {
|
225 |
-
if ( WPCF7_USE_PIPE ) {
|
226 |
-
$values = $tag->pipes->collect_afters();
|
227 |
-
} else {
|
228 |
-
$values = $tag->values;
|
229 |
-
}
|
230 |
-
|
231 |
-
$last = array_pop( $values );
|
232 |
-
$last = html_entity_decode( $last, ENT_QUOTES, 'UTF-8' );
|
233 |
-
|
234 |
-
if ( in_array( $last, $posted_items ) ) {
|
235 |
-
$posted_items = array_diff( $posted_items, array( $last ) );
|
236 |
-
|
237 |
-
$free_text_name = sprintf(
|
238 |
-
'_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name );
|
239 |
-
|
240 |
-
$free_text = $posted_data[$free_text_name];
|
241 |
-
|
242 |
-
if ( ! empty( $free_text ) ) {
|
243 |
-
$posted_items[] = trim( $last . ' ' . $free_text );
|
244 |
-
} else {
|
245 |
-
$posted_items[] = $last;
|
246 |
-
}
|
247 |
-
}
|
248 |
-
}
|
249 |
-
|
250 |
-
$posted_data[$tag->name] = $posted_items;
|
251 |
-
}
|
252 |
-
|
253 |
-
return $posted_data;
|
254 |
-
}
|
255 |
-
|
256 |
-
|
257 |
/* Tag generator */
|
258 |
|
259 |
add_action( 'wpcf7_admin_init',
|
141 |
$class .= ' last';
|
142 |
|
143 |
if ( $free_text ) {
|
144 |
+
$free_text_name = $tag->name . '_free_text';
|
|
|
|
|
145 |
|
146 |
$free_text_atts = array(
|
147 |
'name' => $free_text_name,
|
200 |
}
|
201 |
|
202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
/* Tag generator */
|
204 |
|
205 |
add_action( 'wpcf7_admin_init',
|
modules/file.php
CHANGED
@@ -87,7 +87,7 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
87 |
|
88 |
$file = isset( $_FILES[$name] ) ? $_FILES[$name] : null;
|
89 |
|
90 |
-
if ( $file['error'] and UPLOAD_ERR_NO_FILE !== $file['error'] ) {
|
91 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_failed_php_error' ) );
|
92 |
return $result;
|
93 |
}
|
@@ -97,20 +97,25 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
97 |
return $result;
|
98 |
}
|
99 |
|
100 |
-
if (
|
|
|
101 |
return $result;
|
102 |
}
|
103 |
|
104 |
/* File type validation */
|
105 |
|
106 |
$file_type_pattern = wpcf7_acceptable_filetypes(
|
107 |
-
$tag->get_option( 'filetypes' ), 'regex'
|
|
|
108 |
|
109 |
$file_type_pattern = '/\.(' . $file_type_pattern . ')$/i';
|
110 |
|
111 |
-
if (
|
|
|
112 |
$result->invalidate( $tag,
|
113 |
-
wpcf7_get_message( 'upload_file_type_invalid' )
|
|
|
|
|
114 |
return $result;
|
115 |
}
|
116 |
|
@@ -118,7 +123,7 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
118 |
|
119 |
$allowed_size = $tag->get_limit_option();
|
120 |
|
121 |
-
if ( $allowed_size < $file['size'] ) {
|
122 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_file_too_large' ) );
|
123 |
return $result;
|
124 |
}
|
@@ -132,7 +137,8 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
132 |
$filename = wpcf7_antiscript_file_name( $filename );
|
133 |
|
134 |
$filename = apply_filters( 'wpcf7_upload_file_name', $filename,
|
135 |
-
$file['name'], $tag
|
|
|
136 |
|
137 |
$filename = wp_unique_filename( $uploads_dir, $filename );
|
138 |
$new_file = path_join( $uploads_dir, $filename );
|
@@ -152,6 +158,21 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
152 |
return $result;
|
153 |
}
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
/* Messages */
|
157 |
|
87 |
|
88 |
$file = isset( $_FILES[$name] ) ? $_FILES[$name] : null;
|
89 |
|
90 |
+
if ( ! empty( $file['error'] ) and UPLOAD_ERR_NO_FILE !== $file['error'] ) {
|
91 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_failed_php_error' ) );
|
92 |
return $result;
|
93 |
}
|
97 |
return $result;
|
98 |
}
|
99 |
|
100 |
+
if ( empty( $file['tmp_name'] )
|
101 |
+
or ! is_uploaded_file( $file['tmp_name'] ) ) {
|
102 |
return $result;
|
103 |
}
|
104 |
|
105 |
/* File type validation */
|
106 |
|
107 |
$file_type_pattern = wpcf7_acceptable_filetypes(
|
108 |
+
$tag->get_option( 'filetypes' ), 'regex'
|
109 |
+
);
|
110 |
|
111 |
$file_type_pattern = '/\.(' . $file_type_pattern . ')$/i';
|
112 |
|
113 |
+
if ( empty( $file['name'] )
|
114 |
+
or ! preg_match( $file_type_pattern, $file['name'] ) ) {
|
115 |
$result->invalidate( $tag,
|
116 |
+
wpcf7_get_message( 'upload_file_type_invalid' )
|
117 |
+
);
|
118 |
+
|
119 |
return $result;
|
120 |
}
|
121 |
|
123 |
|
124 |
$allowed_size = $tag->get_limit_option();
|
125 |
|
126 |
+
if ( ! empty( $file['size'] ) and $allowed_size < $file['size'] ) {
|
127 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_file_too_large' ) );
|
128 |
return $result;
|
129 |
}
|
137 |
$filename = wpcf7_antiscript_file_name( $filename );
|
138 |
|
139 |
$filename = apply_filters( 'wpcf7_upload_file_name', $filename,
|
140 |
+
$file['name'], $tag
|
141 |
+
);
|
142 |
|
143 |
$filename = wp_unique_filename( $uploads_dir, $filename );
|
144 |
$new_file = path_join( $uploads_dir, $filename );
|
158 |
return $result;
|
159 |
}
|
160 |
|
161 |
+
add_filter( 'wpcf7_mail_tag_replaced_file', 'wpcf7_file_mail_tag', 10, 4 );
|
162 |
+
add_filter( 'wpcf7_mail_tag_replaced_file*', 'wpcf7_file_mail_tag', 10, 4 );
|
163 |
+
|
164 |
+
function wpcf7_file_mail_tag( $replaced, $submitted, $html, $mail_tag ) {
|
165 |
+
$submission = WPCF7_Submission::get_instance();
|
166 |
+
$uploaded_files = $submission->uploaded_files();
|
167 |
+
$name = $mail_tag->field_name();
|
168 |
+
|
169 |
+
if ( ! empty( $uploaded_files[$name] ) ) {
|
170 |
+
$replaced = wp_basename( $uploaded_files[$name] );
|
171 |
+
}
|
172 |
+
|
173 |
+
return $replaced;
|
174 |
+
}
|
175 |
+
|
176 |
|
177 |
/* Messages */
|
178 |
|
modules/flamingo.php
CHANGED
@@ -35,24 +35,6 @@ function wpcf7_flamingo_submit( $contact_form, $result ) {
|
|
35 |
return;
|
36 |
}
|
37 |
|
38 |
-
$fields_senseless =
|
39 |
-
$contact_form->scan_form_tags( array( 'feature' => 'do-not-store' ) );
|
40 |
-
|
41 |
-
$exclude_names = array();
|
42 |
-
|
43 |
-
foreach ( $fields_senseless as $tag ) {
|
44 |
-
$exclude_names[] = $tag['name'];
|
45 |
-
}
|
46 |
-
|
47 |
-
$exclude_names[] = 'g-recaptcha-response';
|
48 |
-
|
49 |
-
foreach ( $posted_data as $key => $value ) {
|
50 |
-
if ( '_' == substr( $key, 0, 1 )
|
51 |
-
or in_array( $key, $exclude_names ) ) {
|
52 |
-
unset( $posted_data[$key] );
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
$email = wpcf7_flamingo_get_value( 'email', $contact_form );
|
57 |
$name = wpcf7_flamingo_get_value( 'name', $contact_form );
|
58 |
$subject = wpcf7_flamingo_get_value( 'subject', $contact_form );
|
@@ -122,6 +104,7 @@ function wpcf7_flamingo_submit( $contact_form, $result ) {
|
|
122 |
|
123 |
$args = array(
|
124 |
'channel' => $channel,
|
|
|
125 |
'subject' => $subject,
|
126 |
'from' => trim( sprintf( '%s <%s>', $name, $email ) ),
|
127 |
'from_name' => $name,
|
@@ -131,6 +114,8 @@ function wpcf7_flamingo_submit( $contact_form, $result ) {
|
|
131 |
'akismet' => $akismet,
|
132 |
'spam' => ( 'spam' == $result['status'] ),
|
133 |
'consent' => $submission->collect_consent(),
|
|
|
|
|
134 |
);
|
135 |
|
136 |
if ( $args['spam'] ) {
|
@@ -162,19 +147,20 @@ function wpcf7_flamingo_get_value( $field, $contact_form ) {
|
|
162 |
$value = '';
|
163 |
|
164 |
if ( in_array( $field, array( 'email', 'name', 'subject' ) ) ) {
|
165 |
-
$
|
166 |
|
167 |
-
if (
|
168 |
$template = sprintf( '[your-%s]', $field );
|
169 |
} else {
|
170 |
-
$template = trim( wpcf7_strip_quote( $
|
171 |
}
|
172 |
|
173 |
$value = wpcf7_mail_replace_tags( $template );
|
174 |
}
|
175 |
|
176 |
$value = apply_filters( 'wpcf7_flamingo_get_value', $value,
|
177 |
-
$field, $contact_form
|
|
|
178 |
|
179 |
return $value;
|
180 |
}
|
35 |
return;
|
36 |
}
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
$email = wpcf7_flamingo_get_value( 'email', $contact_form );
|
39 |
$name = wpcf7_flamingo_get_value( 'name', $contact_form );
|
40 |
$subject = wpcf7_flamingo_get_value( 'subject', $contact_form );
|
104 |
|
105 |
$args = array(
|
106 |
'channel' => $channel,
|
107 |
+
'status' => $submission->get_status(),
|
108 |
'subject' => $subject,
|
109 |
'from' => trim( sprintf( '%s <%s>', $name, $email ) ),
|
110 |
'from_name' => $name,
|
114 |
'akismet' => $akismet,
|
115 |
'spam' => ( 'spam' == $result['status'] ),
|
116 |
'consent' => $submission->collect_consent(),
|
117 |
+
'timestamp' => $submission->get_meta( 'timestamp' ),
|
118 |
+
'posted_data_hash' => $submission->get_posted_data_hash(),
|
119 |
);
|
120 |
|
121 |
if ( $args['spam'] ) {
|
147 |
$value = '';
|
148 |
|
149 |
if ( in_array( $field, array( 'email', 'name', 'subject' ) ) ) {
|
150 |
+
$template = $contact_form->pref( 'flamingo_' . $field );
|
151 |
|
152 |
+
if ( null === $template ) {
|
153 |
$template = sprintf( '[your-%s]', $field );
|
154 |
} else {
|
155 |
+
$template = trim( wpcf7_strip_quote( $template ) );
|
156 |
}
|
157 |
|
158 |
$value = wpcf7_mail_replace_tags( $template );
|
159 |
}
|
160 |
|
161 |
$value = apply_filters( 'wpcf7_flamingo_get_value', $value,
|
162 |
+
$field, $contact_form
|
163 |
+
);
|
164 |
|
165 |
return $value;
|
166 |
}
|
modules/quiz.php
CHANGED
@@ -96,7 +96,7 @@ function wpcf7_quiz_validation_filter( $result, $tag ) {
|
|
96 |
? (string) $_POST['_wpcf7_quiz_answer_' . $name]
|
97 |
: '';
|
98 |
|
99 |
-
if (
|
100 |
$result->invalidate( $tag, wpcf7_get_message( 'quiz_answer_not_correct' ) );
|
101 |
}
|
102 |
|
@@ -106,8 +106,8 @@ function wpcf7_quiz_validation_filter( $result, $tag ) {
|
|
106 |
|
107 |
/* Ajax echo filter */
|
108 |
|
109 |
-
add_filter( '
|
110 |
-
add_filter( '
|
111 |
|
112 |
function wpcf7_quiz_ajax_refill( $items ) {
|
113 |
if ( ! is_array( $items ) ) {
|
96 |
? (string) $_POST['_wpcf7_quiz_answer_' . $name]
|
97 |
: '';
|
98 |
|
99 |
+
if ( ! hash_equals( $expected_hash, $answer_hash ) ) {
|
100 |
$result->invalidate( $tag, wpcf7_get_message( 'quiz_answer_not_correct' ) );
|
101 |
}
|
102 |
|
106 |
|
107 |
/* Ajax echo filter */
|
108 |
|
109 |
+
add_filter( 'wpcf7_refill_response', 'wpcf7_quiz_ajax_refill', 10, 1 );
|
110 |
+
add_filter( 'wpcf7_feedback_response', 'wpcf7_quiz_ajax_refill', 10, 1 );
|
111 |
|
112 |
function wpcf7_quiz_ajax_refill( $items ) {
|
113 |
if ( ! is_array( $items ) ) {
|
modules/really-simple-captcha.php
CHANGED
@@ -176,8 +176,8 @@ function wpcf7_captcha_validation_filter( $result, $tag ) {
|
|
176 |
|
177 |
/* Ajax echo filter */
|
178 |
|
179 |
-
add_filter( '
|
180 |
-
add_filter( '
|
181 |
|
182 |
function wpcf7_captcha_ajax_refill( $items ) {
|
183 |
if ( ! is_array( $items ) ) {
|
@@ -552,7 +552,7 @@ function wpcf7_cleanup_captcha_files() {
|
|
552 |
|
553 |
$stat = stat( path_join( $dir, $file ) );
|
554 |
|
555 |
-
if ( $stat['mtime'] +
|
556 |
@unlink( path_join( $dir, $file ) );
|
557 |
}
|
558 |
}
|
176 |
|
177 |
/* Ajax echo filter */
|
178 |
|
179 |
+
add_filter( 'wpcf7_refill_response', 'wpcf7_captcha_ajax_refill', 10, 1 );
|
180 |
+
add_filter( 'wpcf7_feedback_response', 'wpcf7_captcha_ajax_refill', 10, 1 );
|
181 |
|
182 |
function wpcf7_captcha_ajax_refill( $items ) {
|
183 |
if ( ! is_array( $items ) ) {
|
552 |
|
553 |
$stat = stat( path_join( $dir, $file ) );
|
554 |
|
555 |
+
if ( $stat['mtime'] + HOUR_IN_SECONDS < time() ) {
|
556 |
@unlink( path_join( $dir, $file ) );
|
557 |
}
|
558 |
}
|
modules/{recaptcha.php → recaptcha/recaptcha.php}
RENAMED
@@ -23,18 +23,40 @@ function wpcf7_recaptcha_enqueue_scripts() {
|
|
23 |
return;
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
29 |
),
|
30 |
-
|
|
|
|
|
31 |
);
|
32 |
|
33 |
-
wp_enqueue_script( '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
add_filter( 'wpcf7_form_hidden_fields',
|
37 |
-
'wpcf7_recaptcha_add_hidden_fields', 100, 1
|
|
|
38 |
|
39 |
function wpcf7_recaptcha_add_hidden_fields( $fields ) {
|
40 |
$service = WPCF7_RECAPTCHA::get_instance();
|
@@ -44,96 +66,10 @@ function wpcf7_recaptcha_add_hidden_fields( $fields ) {
|
|
44 |
}
|
45 |
|
46 |
return array_merge( $fields, array(
|
47 |
-
'
|
48 |
) );
|
49 |
}
|
50 |
|
51 |
-
add_action( 'wp_footer', 'wpcf7_recaptcha_onload_script', 40, 0 );
|
52 |
-
|
53 |
-
function wpcf7_recaptcha_onload_script() {
|
54 |
-
$service = WPCF7_RECAPTCHA::get_instance();
|
55 |
-
|
56 |
-
if ( ! $service->is_active() ) {
|
57 |
-
return;
|
58 |
-
}
|
59 |
-
|
60 |
-
if ( ! wp_script_is( 'google-recaptcha', 'done' ) ) {
|
61 |
-
return;
|
62 |
-
}
|
63 |
-
|
64 |
-
$actions = apply_filters( 'wpcf7_recaptcha_actions',
|
65 |
-
array(
|
66 |
-
'homepage' => 'homepage',
|
67 |
-
'contactform' => 'contactform',
|
68 |
-
)
|
69 |
-
);
|
70 |
-
|
71 |
-
?>
|
72 |
-
<script type="text/javascript">
|
73 |
-
( function( sitekey, actions ) {
|
74 |
-
|
75 |
-
document.addEventListener( 'DOMContentLoaded', function( event ) {
|
76 |
-
var wpcf7recaptcha = {
|
77 |
-
|
78 |
-
execute: function( action ) {
|
79 |
-
grecaptcha.execute(
|
80 |
-
sitekey,
|
81 |
-
{ action: action }
|
82 |
-
).then( function( token ) {
|
83 |
-
var event = new CustomEvent( 'wpcf7grecaptchaexecuted', {
|
84 |
-
detail: {
|
85 |
-
action: action,
|
86 |
-
token: token,
|
87 |
-
},
|
88 |
-
} );
|
89 |
-
|
90 |
-
document.dispatchEvent( event );
|
91 |
-
} );
|
92 |
-
},
|
93 |
-
|
94 |
-
executeOnHomepage: function() {
|
95 |
-
wpcf7recaptcha.execute( actions[ 'homepage' ] );
|
96 |
-
},
|
97 |
-
|
98 |
-
executeOnContactform: function() {
|
99 |
-
wpcf7recaptcha.execute( actions[ 'contactform' ] );
|
100 |
-
},
|
101 |
-
|
102 |
-
};
|
103 |
-
|
104 |
-
grecaptcha.ready(
|
105 |
-
wpcf7recaptcha.executeOnHomepage
|
106 |
-
);
|
107 |
-
|
108 |
-
document.addEventListener( 'change',
|
109 |
-
wpcf7recaptcha.executeOnContactform, false
|
110 |
-
);
|
111 |
-
|
112 |
-
document.addEventListener( 'wpcf7submit',
|
113 |
-
wpcf7recaptcha.executeOnHomepage, false
|
114 |
-
);
|
115 |
-
|
116 |
-
} );
|
117 |
-
|
118 |
-
document.addEventListener( 'wpcf7grecaptchaexecuted', function( event ) {
|
119 |
-
var fields = document.querySelectorAll(
|
120 |
-
"form.wpcf7-form input[name='g-recaptcha-response']"
|
121 |
-
);
|
122 |
-
|
123 |
-
for ( var i = 0; i < fields.length; i++ ) {
|
124 |
-
var field = fields[ i ];
|
125 |
-
field.setAttribute( 'value', event.detail.token );
|
126 |
-
}
|
127 |
-
} );
|
128 |
-
|
129 |
-
} )(
|
130 |
-
'<?php echo esc_js( $service->get_sitekey() ); ?>',
|
131 |
-
<?php echo json_encode( $actions ), "\n"; ?>
|
132 |
-
);
|
133 |
-
</script>
|
134 |
-
<?php
|
135 |
-
}
|
136 |
-
|
137 |
add_filter( 'wpcf7_spam', 'wpcf7_recaptcha_verify_response', 9, 1 );
|
138 |
|
139 |
function wpcf7_recaptcha_verify_response( $spam ) {
|
@@ -149,8 +85,8 @@ function wpcf7_recaptcha_verify_response( $spam ) {
|
|
149 |
|
150 |
$submission = WPCF7_Submission::get_instance();
|
151 |
|
152 |
-
$token = isset( $_POST['
|
153 |
-
? trim( $_POST['
|
154 |
|
155 |
if ( $service->verify( $token ) ) { // Human
|
156 |
$spam = false;
|
23 |
return;
|
24 |
}
|
25 |
|
26 |
+
wp_enqueue_script( 'google-recaptcha',
|
27 |
+
add_query_arg(
|
28 |
+
array(
|
29 |
+
'render' => $service->get_sitekey(),
|
30 |
+
),
|
31 |
+
'https://www.google.com/recaptcha/api.js'
|
32 |
),
|
33 |
+
array(),
|
34 |
+
'3.0',
|
35 |
+
true
|
36 |
);
|
37 |
|
38 |
+
wp_enqueue_script( 'wpcf7-recaptcha',
|
39 |
+
wpcf7_plugin_url( 'modules/recaptcha/script.js' ),
|
40 |
+
array( 'google-recaptcha' ),
|
41 |
+
WPCF7_VERSION,
|
42 |
+
true
|
43 |
+
);
|
44 |
+
|
45 |
+
wp_localize_script( 'wpcf7-recaptcha',
|
46 |
+
'wpcf7_recaptcha',
|
47 |
+
array(
|
48 |
+
'sitekey' => $service->get_sitekey(),
|
49 |
+
'actions' => apply_filters( 'wpcf7_recaptcha_actions', array(
|
50 |
+
'homepage' => 'homepage',
|
51 |
+
'contactform' => 'contactform',
|
52 |
+
) ),
|
53 |
+
)
|
54 |
+
);
|
55 |
}
|
56 |
|
57 |
add_filter( 'wpcf7_form_hidden_fields',
|
58 |
+
'wpcf7_recaptcha_add_hidden_fields', 100, 1
|
59 |
+
);
|
60 |
|
61 |
function wpcf7_recaptcha_add_hidden_fields( $fields ) {
|
62 |
$service = WPCF7_RECAPTCHA::get_instance();
|
66 |
}
|
67 |
|
68 |
return array_merge( $fields, array(
|
69 |
+
'_wpcf7_recaptcha_response' => '',
|
70 |
) );
|
71 |
}
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
add_filter( 'wpcf7_spam', 'wpcf7_recaptcha_verify_response', 9, 1 );
|
74 |
|
75 |
function wpcf7_recaptcha_verify_response( $spam ) {
|
85 |
|
86 |
$submission = WPCF7_Submission::get_instance();
|
87 |
|
88 |
+
$token = isset( $_POST['_wpcf7_recaptcha_response'] )
|
89 |
+
? trim( $_POST['_wpcf7_recaptcha_response'] ) : '';
|
90 |
|
91 |
if ( $service->verify( $token ) ) { // Human
|
92 |
$spam = false;
|
modules/recaptcha/script.js
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
( function() {
|
2 |
+
document.addEventListener( 'DOMContentLoaded', function( event ) {
|
3 |
+
|
4 |
+
wpcf7_recaptcha.execute = function( action ) {
|
5 |
+
grecaptcha.execute(
|
6 |
+
wpcf7_recaptcha.sitekey,
|
7 |
+
{ action: action }
|
8 |
+
).then( function( token ) {
|
9 |
+
var event = new CustomEvent( 'wpcf7grecaptchaexecuted', {
|
10 |
+
detail: {
|
11 |
+
action: action,
|
12 |
+
token: token,
|
13 |
+
},
|
14 |
+
} );
|
15 |
+
|
16 |
+
document.dispatchEvent( event );
|
17 |
+
} );
|
18 |
+
};
|
19 |
+
|
20 |
+
wpcf7_recaptcha.execute_on_homepage = function() {
|
21 |
+
wpcf7_recaptcha.execute( wpcf7_recaptcha.actions[ 'homepage' ] );
|
22 |
+
};
|
23 |
+
|
24 |
+
wpcf7_recaptcha.execute_on_contactform = function() {
|
25 |
+
wpcf7_recaptcha.execute( wpcf7_recaptcha.actions[ 'contactform' ] );
|
26 |
+
};
|
27 |
+
|
28 |
+
grecaptcha.ready(
|
29 |
+
wpcf7_recaptcha.execute_on_homepage
|
30 |
+
);
|
31 |
+
|
32 |
+
document.addEventListener( 'change',
|
33 |
+
wpcf7_recaptcha.execute_on_contactform
|
34 |
+
);
|
35 |
+
|
36 |
+
document.addEventListener( 'wpcf7submit',
|
37 |
+
wpcf7_recaptcha.execute_on_homepage
|
38 |
+
);
|
39 |
+
|
40 |
+
} );
|
41 |
+
|
42 |
+
document.addEventListener( 'wpcf7grecaptchaexecuted', function( event ) {
|
43 |
+
var fields = document.querySelectorAll(
|
44 |
+
"form.wpcf7-form input[name='_wpcf7_recaptcha_response']"
|
45 |
+
);
|
46 |
+
|
47 |
+
for ( var i = 0; i < fields.length; i++ ) {
|
48 |
+
var field = fields[ i ];
|
49 |
+
field.setAttribute( 'value', event.detail.token );
|
50 |
+
}
|
51 |
+
} );
|
52 |
+
|
53 |
+
} )();
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: takayukister
|
3 |
Donate link: https://contactform7.com/donate/
|
4 |
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
|
5 |
-
Requires at least:
|
6 |
Tested up to: 5.4
|
7 |
-
Stable tag: 5.
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -75,6 +75,18 @@ Do you have questions or issues with Contact Form 7? Use these support channels
|
|
75 |
|
76 |
For more information, see [Releases](https://contactform7.com/category/releases/).
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
= 5.1.9 =
|
79 |
|
80 |
* Special mail-tags: Reflects WP timezone to `[_date]` and `[_time]` mail-tags.
|
@@ -135,66 +147,4 @@ For more information, see [Releases](https://contactform7.com/category/releases/
|
|
135 |
* Updates the reCAPTCHA module to support reCAPTCHA v3.
|
136 |
* Adds Dark Mode style rules.
|
137 |
|
138 |
-
= 5.0.5 =
|
139 |
-
|
140 |
-
* Fixes the inconsistency problem between get_data_option() and get_default_option() in the WPCF7_FormTag class.
|
141 |
-
* Suppresses PHP errors occur on unlink() calls.
|
142 |
-
* Introduces wpcf7_is_file_path_in_content_dir() to support the use of the UPLOADS constant.
|
143 |
-
|
144 |
-
= 5.0.4 =
|
145 |
-
|
146 |
-
* Specifies the capability_type argument explicitly in the register_post_type() call to fix the privilege escalation vulnerability issue.
|
147 |
-
* Local File Attachment – disallows the specifying of absolute file paths referring to files outside the wp-content directory.
|
148 |
-
* Config Validator – adds a test item to detect invalid file attachment settings.
|
149 |
-
* Fixes a bug in the JavaScript fallback function for legacy browsers that do not support the HTML5 placeholder attribute.
|
150 |
-
* Acceptance Checkbox – unsets the form-tag's do-not-store feature.
|
151 |
-
|
152 |
-
= 5.0.3 =
|
153 |
-
|
154 |
-
* CSS: Applies the "not-allowed" cursor style to submit buttons in the "disabled" state.
|
155 |
-
* Acceptance Checkbox: Revises the tag-generator UI to encourage the use of better options in terms of personal data protection.
|
156 |
-
* Introduces wpcf7_anonymize_ip_addr() function.
|
157 |
-
* Introduces the consent_for:storage option for all types of form-tags.
|
158 |
-
|
159 |
-
= 5.0.2 =
|
160 |
-
|
161 |
-
* Added the Privacy Notices section to the readme.txt file.
|
162 |
-
* Updated the Information meta-box content.
|
163 |
-
* Use get_user_locale() instead of get_locale() where it is more appropriate.
|
164 |
-
* Acceptance Checkbox: Reset submit buttons’ disabled status after a successful submission.
|
165 |
-
|
166 |
-
= 5.0.1 =
|
167 |
-
|
168 |
-
* Fixed incorrect uses of _n().
|
169 |
-
* Config validation: Fixed incorrect count of alerts in the Additional Settings tab panel.
|
170 |
-
* Config validation: Fixed improper treatment for the [_site_admin_email] special mail-tag in the From mail header field.
|
171 |
-
* Acceptance checkbox: The class and id attributes specified were applied to the wrong HTML element.
|
172 |
-
* Config validation: When there is an additional mail header for mailboxes like Cc or Reply-To, but it has a possible empty value, “Invalid mailbox syntax is used” error will be returned.
|
173 |
-
* Explicitly specify the fourth parameter of add_action() to avoid passing unintended parameter values.
|
174 |
-
* Check if the target directory is empty before removing the directory.
|
175 |
-
|
176 |
-
= 5.0 =
|
177 |
-
|
178 |
-
* Additional settings: on_sent_ok and on_submit have been removed.
|
179 |
-
* New additional setting: skip_mail
|
180 |
-
* Flamingo: Inbound channel title changes in conjunction with a change in the title of the corresponding contact form.
|
181 |
-
* DOM events: Make an entire API response object accessible through the event.detail.apiResponse property.
|
182 |
-
* HTML mail: Adds language-related attributes to the HTML header.
|
183 |
-
* File upload: Sets the accept attribute to an uploading field.
|
184 |
-
* Introduces the WPCF7_MailTag class.
|
185 |
-
* Allows aborting a mail-sending attempt using the wpcf7_before_send_mail action hook. Also, you can set a custom status and a message through the action hook.
|
186 |
-
* Acceptance checkbox: Allows the specifying of a statement of conditions in the form-tag’s content part.
|
187 |
-
* Acceptance checkbox: Supports the optional option.
|
188 |
-
* New special mail tags: [_site_title], [_site_description], [_site_url], [_site_admin_email], [_invalid_fields], [_user_login], [_user_email], [_user_url], [_user_first_name], [_user_last_name], [_user_nickname], and [_user_display_name]
|
189 |
-
* New filter hooks: wpcf7_upload_file_name, wpcf7_autop_or_not, wpcf7_posted_data_{$type}, and wpcf7_mail_tag_replaced_{$type}
|
190 |
-
* New form-tag features: zero-controls-container and not-for-mail
|
191 |
-
|
192 |
== Upgrade Notice ==
|
193 |
-
|
194 |
-
= 5.1.1 =
|
195 |
-
|
196 |
-
Read the [release announcement post](https://contactform7.com/category/releases/) before upgrading. There is an important notice.
|
197 |
-
|
198 |
-
= 5.0.4 =
|
199 |
-
|
200 |
-
This is a security and maintenance release and we strongly encourage you to update to it immediately. For more information, refer to the [release announcement post](https://contactform7.com/category/releases/).
|
2 |
Contributors: takayukister
|
3 |
Donate link: https://contactform7.com/donate/
|
4 |
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
|
5 |
+
Requires at least: 5.3
|
6 |
Tested up to: 5.4
|
7 |
+
Stable tag: 5.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
75 |
|
76 |
For more information, see [Releases](https://contactform7.com/category/releases/).
|
77 |
|
78 |
+
= 5.2 =
|
79 |
+
|
80 |
+
* Submission: Introduces the `$posted_data_hash` and `$skip_spam_check` properties.
|
81 |
+
* Submission: Introduces the `wpcf7_skip_spam_check` filter hook.
|
82 |
+
* Contact form: Introduces the `pref()` method.
|
83 |
+
* REST API: Adds parsed form-tags data to the response.
|
84 |
+
* REST API: Deprecates the `wpcf7_ajax_json_echo` and `wpcf7_ajax_onload` filter hooks and introduces the `wpcf7_feedback_response` and `wpcf7_refill_response` filter hooks as alternatives.
|
85 |
+
* Frontend CSS: Style rules for the response output refer to the `form` element’s `class` attribute.
|
86 |
+
* Frontend JavaScript: Abolishes the use of jQuery events.
|
87 |
+
* reCAPTCHA: Moves script code to a separate file.
|
88 |
+
* reCAPTCHA: Changes the name of the field for reCAPTCHA response token from `g-recaptcha-response` to `_wpcf7_recaptcha_response`.
|
89 |
+
|
90 |
= 5.1.9 =
|
91 |
|
92 |
* Special mail-tags: Reflects WP timezone to `[_date]` and `[_time]` mail-tags.
|
147 |
* Updates the reCAPTCHA module to support reCAPTCHA v3.
|
148 |
* Adds Dark Mode style rules.
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
== Upgrade Notice ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings.php
CHANGED
@@ -56,11 +56,19 @@ class WPCF7 {
|
|
56 |
return false;
|
57 |
}
|
58 |
|
59 |
-
$
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
|
|
|
|
64 |
}
|
65 |
|
66 |
public static function get_option( $name, $default = false ) {
|
56 |
return false;
|
57 |
}
|
58 |
|
59 |
+
$files = array(
|
60 |
+
path_join( $dir, $mod . '/' . $mod . '.php' ),
|
61 |
+
path_join( $dir, $mod . '.php' ),
|
62 |
+
);
|
63 |
+
|
64 |
+
foreach ( $files as $file ) {
|
65 |
+
if ( file_exists( $file ) ) {
|
66 |
+
include_once $file;
|
67 |
+
return true;
|
68 |
+
}
|
69 |
}
|
70 |
+
|
71 |
+
return false;
|
72 |
}
|
73 |
|
74 |
public static function get_option( $name, $default = false ) {
|
wp-contact-form-7.php
CHANGED
@@ -7,12 +7,12 @@ Author: Takayuki Miyoshi
|
|
7 |
Author URI: https://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
-
Version: 5.
|
11 |
*/
|
12 |
|
13 |
-
define( 'WPCF7_VERSION', '5.
|
14 |
|
15 |
-
define( 'WPCF7_REQUIRED_WP_VERSION', '
|
16 |
|
17 |
define( 'WPCF7_PLUGIN', __FILE__ );
|
18 |
|
7 |
Author URI: https://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
+
Version: 5.2
|
11 |
*/
|
12 |
|
13 |
+
define( 'WPCF7_VERSION', '5.2' );
|
14 |
|
15 |
+
define( 'WPCF7_REQUIRED_WP_VERSION', '5.3' );
|
16 |
|
17 |
define( 'WPCF7_PLUGIN', __FILE__ );
|
18 |
|