Contact Form 7 - Version 5.1.8

Version Description

  • reCAPTCHA: Shows no warning on upgrading from v2 if the global sitekey is defined.
  • reCAPTCHA: Improves the frontend JavaScript coding.
  • Accessibility: Improves the response message markup.
  • Fixes the regular expression pattern in wpcf7_is_tel().
  • Fixed: Character count was not reset after a successful submission.
  • Fixed: The fourth parameter of the wpcf7_special_mail_tags filter hook was not correctly set.
Download this release

Release Info

Developer takayukister
Plugin Icon 128x128 Contact Form 7
Version 5.1.8
Comparing to
See all releases

Code changes from version 5.1.7 to 5.1.8

admin/includes/config-validator.php CHANGED
@@ -69,7 +69,7 @@ function wpcf7_load_bulk_validate_page( $page, $action ) {
69
$contact_forms = WPCF7_ContactForm::find();
70
71
$result = array(
72
- 'timestamp' => current_time( 'timestamp' ),
73
'version' => WPCF7_VERSION,
74
'count_valid' => 0,
75
'count_invalid' => 0,
69
$contact_forms = WPCF7_ContactForm::find();
70
71
$result = array(
72
+ 'timestamp' => time(),
73
'version' => WPCF7_VERSION,
74
'count_valid' => 0,
75
'count_invalid' => 0,
includes/contact-form.php CHANGED
@@ -520,15 +520,18 @@ class WPCF7_ContactForm {
520
$atts = array(
521
'class' => trim( $class ),
522
'role' => trim( $role ),
523
);
524
525
$atts = wpcf7_format_atts( $atts );
526
527
$output = sprintf( '<div %1$s>%2$s</div>',
528
- $atts, esc_html( $content ) );
529
530
$output = apply_filters( 'wpcf7_form_response_output',
531
- $output, $class, $content, $this, $status );
532
533
$this->responses_count += 1;
534
@@ -560,7 +563,8 @@ class WPCF7_ContactForm {
560
$content .= sprintf( '<li>%s</li>', $link );
561
} else {
562
$content .= sprintf( '<li>%s</li>',
563
- esc_html( $field['reason'] ) );
564
}
565
566
$content .= "\n";
@@ -572,12 +576,15 @@ class WPCF7_ContactForm {
572
573
$atts = array(
574
'class' => trim( $class ),
575
- 'role' => trim( $role ) );
576
577
$atts = wpcf7_format_atts( $atts );
578
579
$output = sprintf( '<div %1$s>%2$s</div>',
580
- $atts, $content );
581
582
return $output;
583
}
@@ -597,9 +604,17 @@ class WPCF7_ContactForm {
597
return $error;
598
}
599
600
$error = sprintf(
601
- '<span role="alert" class="wpcf7-not-valid-tip">%s</span>',
602
- esc_html( $error ) );
603
604
return apply_filters( 'wpcf7_validation_error', $error, $name, $this );
605
}
520
$atts = array(
521
'class' => trim( $class ),
522
'role' => trim( $role ),
523
+ 'aria-hidden' => 'true',
524
);
525
526
$atts = wpcf7_format_atts( $atts );
527
528
$output = sprintf( '<div %1$s>%2$s</div>',
529
+ $atts, esc_html( $content )
530
+ );
531
532
$output = apply_filters( 'wpcf7_form_response_output',
533
+ $output, $class, $content, $this, $status
534
+ );
535
536
$this->responses_count += 1;
537
563
$content .= sprintf( '<li>%s</li>', $link );
564
} else {
565
$content .= sprintf( '<li>%s</li>',
566
+ esc_html( $field['reason'] )
567
+ );
568
}
569
570
$content .= "\n";
576
577
$atts = array(
578
'class' => trim( $class ),
579
+ 'role' => trim( $role ),
580
+ 'aria-live' => 'polite',
581
+ );
582
583
$atts = wpcf7_format_atts( $atts );
584
585
$output = sprintf( '<div %1$s>%2$s</div>',
586
+ $atts, $content
587
+ );
588
589
return $output;
590
}
604
return $error;
605
}
606
607
+ $atts = array(
608
+ 'class' => 'wpcf7-not-valid-tip',
609
+ 'role' => 'alert',
610
+ 'aria-hidden' => 'true',
611
+ );
612
+
613
$error = sprintf(
614
+ '<span %1$s>%2$s</span>',
615
+ wpcf7_format_atts( $atts ),
616
+ esc_html( $error )
617
+ );
618
619
return apply_filters( 'wpcf7_validation_error', $error, $name, $this );
620
}
includes/formatting.php CHANGED
@@ -209,7 +209,13 @@ function wpcf7_is_url( $url ) {
209
}
210
211
function wpcf7_is_tel( $tel ) {
212
- $result = preg_match( '%^[+]?[0-9()/ -]*$%', $tel );
213
return apply_filters( 'wpcf7_is_tel', $result, $tel );
214
}
215
209
}
210
211
function wpcf7_is_tel( $tel ) {
212
+ $pattern = '%^[+]?' // + sign
213
+ . '(?:\([0-9]+\)|[0-9]+)' // (1234) or 1234
214
+ . '(?:[/ -]*' // delimiter
215
+ . '(?:\([0-9]+\)|[0-9]+)' // (1234) or 1234
216
+ . ')*$%';
217
+
218
+ $result = preg_match( $pattern, trim( $tel ) );
219
return apply_filters( 'wpcf7_is_tel', $result, $tel );
220
}
221
includes/js/scripts.js CHANGED
@@ -136,42 +136,7 @@
136
}
137
138
// Character Count
139
- $( '.wpcf7-character-count', $form ).each( function() {
140
- var $count = $( this );
141
- var name = $count.attr( 'data-target-name' );
142
- var down = $count.hasClass( 'down' );
143
- var starting = parseInt( $count.attr( 'data-starting-value' ), 10 );
144
- var maximum = parseInt( $count.attr( 'data-maximum-value' ), 10 );
145
- var minimum = parseInt( $count.attr( 'data-minimum-value' ), 10 );
146
-
147
- var updateCount = function( target ) {
148
- var $target = $( target );
149
- var length = $target.val().length;
150
- var count = down ? starting - length : length;
151
- $count.attr( 'data-current-value', count );
152
- $count.text( count );
153
-
154
- if ( maximum && maximum < length ) {
155
- $count.addClass( 'too-long' );
156
- } else {
157
- $count.removeClass( 'too-long' );
158
- }
159
-
160
- if ( minimum && length < minimum ) {
161
- $count.addClass( 'too-short' );
162
- } else {
163
- $count.removeClass( 'too-short' );
164
- }
165
- };
166
-
167
- $( ':input[name="' + name + '"]', $form ).each( function() {
168
- updateCount( this );
169
-
170
- $( this ).keyup( function() {
171
- updateCount( this );
172
- } );
173
- } );
174
- } );
175
176
// URL Input Correction
177
$form.on( 'change', '.wpcf7-validates-as-url', function() {
@@ -303,6 +268,7 @@
303
} );
304
305
wpcf7.toggleSubmit( $form );
306
}
307
308
if ( ! wpcf7.supportHtml5.placeholder ) {
@@ -400,11 +366,56 @@
400
} );
401
};
402
403
wpcf7.notValidTip = function( target, message ) {
404
var $target = $( target );
405
$( '.wpcf7-not-valid-tip', $target ).remove();
406
- $( '<span role="alert" class="wpcf7-not-valid-tip"></span>' )
407
- .text( message ).appendTo( $target );
408
409
if ( $target.is( '.use-floating-validation-tip *' ) ) {
410
var fadeOut = function( target ) {
136
}
137
138
// Character Count
139
+ wpcf7.resetCounter( $form );
140
141
// URL Input Correction
142
$form.on( 'change', '.wpcf7-validates-as-url', function() {
268
} );
269
270
wpcf7.toggleSubmit( $form );
271
+ wpcf7.resetCounter( $form );
272
}
273
274
if ( ! wpcf7.supportHtml5.placeholder ) {
366
} );
367
};
368
369
+ wpcf7.resetCounter = function( form ) {
370
+ var $form = $( form );
371
+
372
+ $( '.wpcf7-character-count', $form ).each( function() {
373
+ var $count = $( this );
374
+ var name = $count.attr( 'data-target-name' );
375
+ var down = $count.hasClass( 'down' );
376
+ var starting = parseInt( $count.attr( 'data-starting-value' ), 10 );
377
+ var maximum = parseInt( $count.attr( 'data-maximum-value' ), 10 );
378
+ var minimum = parseInt( $count.attr( 'data-minimum-value' ), 10 );
379
+
380
+ var updateCount = function( target ) {
381
+ var $target = $( target );
382
+ var length = $target.val().length;
383
+ var count = down ? starting - length : length;
384
+ $count.attr( 'data-current-value', count );
385
+ $count.text( count );
386
+
387
+ if ( maximum && maximum < length ) {
388
+ $count.addClass( 'too-long' );
389
+ } else {
390
+ $count.removeClass( 'too-long' );
391
+ }
392
+
393
+ if ( minimum && length < minimum ) {
394
+ $count.addClass( 'too-short' );
395
+ } else {
396
+ $count.removeClass( 'too-short' );
397
+ }
398
+ };
399
+
400
+ $( ':input[name="' + name + '"]', $form ).each( function() {
401
+ updateCount( this );
402
+
403
+ $( this ).keyup( function() {
404
+ updateCount( this );
405
+ } );
406
+ } );
407
+ } );
408
+ };
409
+
410
wpcf7.notValidTip = function( target, message ) {
411
var $target = $( target );
412
$( '.wpcf7-not-valid-tip', $target ).remove();
413
+
414
+ $( '<span></span>' ).attr( {
415
+ 'class': 'wpcf7-not-valid-tip',
416
+ 'role': 'alert',
417
+ 'aria-hidden': 'true',
418
+ } ).text( message ).appendTo( $target );
419
420
if ( $target.is( '.use-floating-validation-tip *' ) ) {
421
var fadeOut = function( target ) {
includes/mail.php CHANGED
@@ -353,7 +353,8 @@ class WPCF7_MailTaggedText {
353
}
354
355
$special = apply_filters( 'wpcf7_special_mail_tags', null,
356
- $mail_tag->tag_name(), $html, $mail_tag );
357
358
if ( null !== $special ) {
359
$this->replaced_tags[$tag] = $special;
353
}
354
355
$special = apply_filters( 'wpcf7_special_mail_tags', null,
356
+ $mail_tag->tag_name(), $html, $mail_tag
357
+ );
358
359
if ( null !== $special ) {
360
$this->replaced_tags[$tag] = $special;
includes/submission.php CHANGED
@@ -170,7 +170,7 @@ class WPCF7_Submission {
170
'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] )
171
? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '',
172
'url' => $this->get_request_url(),
173
- 'timestamp' => current_time( 'timestamp' ),
174
'unit_tag' =>
175
isset( $_POST['_wpcf7_unit_tag'] ) ? $_POST['_wpcf7_unit_tag'] : '',
176
'container_post_id' => isset( $_POST['_wpcf7_container_post'] )
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'] )
modules/akismet.php CHANGED
@@ -15,7 +15,9 @@ function wpcf7_akismet( $spam ) {
15
return false;
16
}
17
18
- if ( ! $params = wpcf7_akismet_submitted_params() ) {
19
return false;
20
}
21
@@ -32,9 +34,8 @@ function wpcf7_akismet( $spam ) {
32
$c['user_ip'] = $_SERVER['REMOTE_ADDR'];
33
$c['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
34
$c['referrer'] = $_SERVER['HTTP_REFERER'];
35
-
36
- // http://blog.akismet.com/2012/06/19/pro-tip-tell-us-your-comment_type/
37
$c['comment_type'] = 'contact-form';
38
39
if ( $permalink = get_permalink() ) {
40
$c['permalink'] = $permalink;
@@ -51,8 +52,6 @@ function wpcf7_akismet( $spam ) {
51
if ( wpcf7_akismet_comment_check( $c ) ) {
52
$spam = true;
53
54
- $submission = WPCF7_Submission::get_instance();
55
-
56
$submission->add_spam_log( array(
57
'agent' => 'akismet',
58
'reason' => __( "Akismet returns a spam response.", 'contact-form-7' ),
15
return false;
16
}
17
18
+ $submission = WPCF7_Submission::get_instance();
19
+
20
+ if ( ! $submission or ! $params = wpcf7_akismet_submitted_params() ) {
21
return false;
22
}
23
34
$c['user_ip'] = $_SERVER['REMOTE_ADDR'];
35
$c['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
36
$c['referrer'] = $_SERVER['HTTP_REFERER'];
37
$c['comment_type'] = 'contact-form';
38
+ $c['comment_date_gmt'] = $submission->get_meta( 'timestamp' );
39
40
if ( $permalink = get_permalink() ) {
41
$c['permalink'] = $permalink;
52
if ( wpcf7_akismet_comment_check( $c ) ) {
53
$spam = true;
54
55
$submission->add_spam_log( array(
56
'agent' => 'akismet',
57
'reason' => __( "Akismet returns a spam response.", 'contact-form-7' ),
modules/checkbox.php CHANGED
@@ -112,11 +112,13 @@ function wpcf7_checkbox_form_tag_handler( $tag ) {
112
if ( $label_first ) { // put label first, input last
113
$item = sprintf(
114
'<span class="wpcf7-list-item-label">%1$s</span><input %2$s />',
115
- esc_html( $label ), $item_atts );
116
} else {
117
$item = sprintf(
118
'<input %2$s /><span class="wpcf7-list-item-label">%1$s</span>',
119
- esc_html( $label ), $item_atts );
120
}
121
122
if ( $use_label_element ) {
@@ -140,7 +142,8 @@ function wpcf7_checkbox_form_tag_handler( $tag ) {
140
141
if ( $free_text ) {
142
$free_text_name = sprintf(
143
- '_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name );
144
145
$free_text_atts = array(
146
'name' => $free_text_name,
@@ -170,7 +173,8 @@ function wpcf7_checkbox_form_tag_handler( $tag ) {
170
171
$html = sprintf(
172
'<span class="wpcf7-form-control-wrap %1$s"><span %2$s>%3$s</span>%4$s</span>',
173
- sanitize_html_class( $tag->name ), $atts, $html, $validation_error );
174
175
return $html;
176
}
112
if ( $label_first ) { // put label first, input last
113
$item = sprintf(
114
'<span class="wpcf7-list-item-label">%1$s</span><input %2$s />',
115
+ esc_html( $label ), $item_atts
116
+ );
117
} else {
118
$item = sprintf(
119
'<input %2$s /><span class="wpcf7-list-item-label">%1$s</span>',
120
+ esc_html( $label ), $item_atts
121
+ );
122
}
123
124
if ( $use_label_element ) {
142
143
if ( $free_text ) {
144
$free_text_name = sprintf(
145
+ '_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name
146
+ );
147
148
$free_text_atts = array(
149
'name' => $free_text_name,
173
174
$html = sprintf(
175
'<span class="wpcf7-form-control-wrap %1$s"><span %2$s>%3$s</span>%4$s</span>',
176
+ sanitize_html_class( $tag->name ), $atts, $html, $validation_error
177
+ );
178
179
return $html;
180
}
modules/constant-contact.php CHANGED
@@ -316,7 +316,10 @@ class WPCF7_ConstantContact extends WPCF7_Service_OAuth2 {
316
317
public function email_exists( $email ) {
318
$endpoint = add_query_arg(
319
- array( 'email' => $email ),
320
'https://api.cc.email/v3/contacts'
321
);
322
@@ -884,9 +887,10 @@ class WPCF7_ConstantContact_ContactPostRequest {
884
public function add_phone_number( $phone_number, $kind = 'home' ) {
885
$phone_number = trim( $phone_number );
886
887
- if ( 2 <= count( $this->phone_numbers )
888
or ! wpcf7_is_tel( $phone_number )
889
or 25 < $this->strlen( $phone_number )
890
or ! in_array( $kind, array( 'home', 'work', 'other' ) ) ) {
891
return false;
892
}
316
317
public function email_exists( $email ) {
318
$endpoint = add_query_arg(
319
+ array(
320
+ 'email' => $email,
321
+ 'status' => 'all',
322
+ ),
323
'https://api.cc.email/v3/contacts'
324
);
325
887
public function add_phone_number( $phone_number, $kind = 'home' ) {
888
$phone_number = trim( $phone_number );
889
890
+ if ( empty( $phone_number )
891
or ! wpcf7_is_tel( $phone_number )
892
or 25 < $this->strlen( $phone_number )
893
+ or 2 <= count( $this->phone_numbers )
894
or ! in_array( $kind, array( 'home', 'work', 'other' ) ) ) {
895
return false;
896
}
modules/date.php CHANGED
@@ -10,7 +10,11 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_date', 10, 0 );
10
11
function wpcf7_add_form_tag_date() {
12
wpcf7_add_form_tag( array( 'date', 'date*' ),
13
- 'wpcf7_date_form_tag_handler', array( 'name-attr' => true ) );
14
}
15
16
function wpcf7_date_form_tag_handler( $tag ) {
@@ -73,7 +77,8 @@ function wpcf7_date_form_tag_handler( $tag ) {
73
74
$html = sprintf(
75
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
76
- sanitize_html_class( $tag->name ), $atts, $validation_error );
77
78
return $html;
79
}
@@ -94,13 +99,13 @@ function wpcf7_date_validation_filter( $result, $tag ) {
94
? trim( strtr( (string) $_POST[$name], "\n", " " ) )
95
: '';
96
97
- if ( $tag->is_required() and '' == $value ) {
98
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
99
- } elseif ( '' != $value and ! wpcf7_is_date( $value ) ) {
100
$result->invalidate( $tag, wpcf7_get_message( 'invalid_date' ) );
101
- } elseif ( '' != $value and ! empty( $min ) and $value < $min ) {
102
$result->invalidate( $tag, wpcf7_get_message( 'date_too_early' ) );
103
- } elseif ( '' != $value and ! empty( $max ) and $max < $value ) {
104
$result->invalidate( $tag, wpcf7_get_message( 'date_too_late' ) );
105
}
106
@@ -116,17 +121,17 @@ function wpcf7_date_messages( $messages ) {
116
return array_merge( $messages, array(
117
'invalid_date' => array(
118
'description' => __( "Date format that the sender entered is invalid", 'contact-form-7' ),
119
- 'default' => __( "The date format is incorrect.", 'contact-form-7' )
120
),
121
122
'date_too_early' => array(
123
'description' => __( "Date is earlier than minimum limit", 'contact-form-7' ),
124
- 'default' => __( "The date is before the earliest one allowed.", 'contact-form-7' )
125
),
126
127
'date_too_late' => array(
128
'description' => __( "Date is later than maximum limit", 'contact-form-7' ),
129
- 'default' => __( "The date is after the latest one allowed.", 'contact-form-7' )
130
),
131
) );
132
}
10
11
function wpcf7_add_form_tag_date() {
12
wpcf7_add_form_tag( array( 'date', 'date*' ),
13
+ 'wpcf7_date_form_tag_handler',
14
+ array(
15
+ 'name-attr' => true,
16
+ )
17
+ );
18
}
19
20
function wpcf7_date_form_tag_handler( $tag ) {
77
78
$html = sprintf(
79
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
80
+ sanitize_html_class( $tag->name ), $atts, $validation_error
81
+ );
82
83
return $html;
84
}
99
? trim( strtr( (string) $_POST[$name], "\n", " " ) )
100
: '';
101
102
+ if ( $tag->is_required() and '' === $value ) {
103
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
104
+ } elseif ( '' !== $value and ! wpcf7_is_date( $value ) ) {
105
$result->invalidate( $tag, wpcf7_get_message( 'invalid_date' ) );
106
+ } elseif ( '' !== $value and ! empty( $min ) and $value < $min ) {
107
$result->invalidate( $tag, wpcf7_get_message( 'date_too_early' ) );
108
+ } elseif ( '' !== $value and ! empty( $max ) and $max < $value ) {
109
$result->invalidate( $tag, wpcf7_get_message( 'date_too_late' ) );
110
}
111
121
return array_merge( $messages, array(
122
'invalid_date' => array(
123
'description' => __( "Date format that the sender entered is invalid", 'contact-form-7' ),
124
+ 'default' => __( "The date format is incorrect.", 'contact-form-7' ),
125
),
126
127
'date_too_early' => array(
128
'description' => __( "Date is earlier than minimum limit", 'contact-form-7' ),
129
+ 'default' => __( "The date is before the earliest one allowed.", 'contact-form-7' ),
130
),
131
132
'date_too_late' => array(
133
'description' => __( "Date is later than maximum limit", 'contact-form-7' ),
134
+ 'default' => __( "The date is after the latest one allowed.", 'contact-form-7' ),
135
),
136
) );
137
}
modules/file.php CHANGED
@@ -9,7 +9,11 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_file', 10, 0 );
9
10
function wpcf7_add_form_tag_file() {
11
wpcf7_add_form_tag( array( 'file', 'file*' ),
12
- 'wpcf7_file_form_tag_handler', array( 'name-attr' => true ) );
13
}
14
15
function wpcf7_file_form_tag_handler( $tag ) {
@@ -48,7 +52,8 @@ function wpcf7_file_form_tag_handler( $tag ) {
48
49
$html = sprintf(
50
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
51
- sanitize_html_class( $tag->name ), $atts, $validation_error );
52
53
return $html;
54
}
@@ -60,7 +65,8 @@ add_filter( 'wpcf7_form_enctype', 'wpcf7_file_form_enctype_filter', 10, 1 );
60
61
function wpcf7_file_form_enctype_filter( $enctype ) {
62
$multipart = (bool) wpcf7_scan_form_tags(
63
- array( 'type' => array( 'file', 'file*' ) ) );
64
65
if ( $multipart ) {
66
$enctype = 'multipart/form-data';
@@ -81,7 +87,7 @@ function wpcf7_file_validation_filter( $result, $tag ) {
81
82
$file = isset( $_FILES[$name] ) ? $_FILES[$name] : null;
83
84
- if ( $file['error'] and UPLOAD_ERR_NO_FILE != $file['error'] ) {
85
$result->invalidate( $tag, wpcf7_get_message( 'upload_failed_php_error' ) );
86
return $result;
87
}
9
10
function wpcf7_add_form_tag_file() {
11
wpcf7_add_form_tag( array( 'file', 'file*' ),
12
+ 'wpcf7_file_form_tag_handler',
13
+ array(
14
+ 'name-attr' => true,
15
+ )
16
+ );
17
}
18
19
function wpcf7_file_form_tag_handler( $tag ) {
52
53
$html = sprintf(
54
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
55
+ sanitize_html_class( $tag->name ), $atts, $validation_error
56
+ );
57
58
return $html;
59
}
65
66
function wpcf7_file_form_enctype_filter( $enctype ) {
67
$multipart = (bool) wpcf7_scan_form_tags(
68
+ array( 'type' => array( 'file', 'file*' ) )
69
+ );
70
71
if ( $multipart ) {
72
$enctype = 'multipart/form-data';
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
}
modules/flamingo.php CHANGED
@@ -63,11 +63,21 @@ function wpcf7_flamingo_submit( $contact_form, $result ) {
63
'user_agent', 'url', 'date', 'time', 'post_id', 'post_name',
64
'post_title', 'post_url', 'post_author', 'post_author_email',
65
'site_title', 'site_description', 'site_url', 'site_admin_email',
66
- 'user_login', 'user_email', 'user_display_name' );
67
68
foreach ( $special_mail_tags as $smt ) {
69
- $meta[$smt] = apply_filters( 'wpcf7_special_mail_tags', '',
70
- sprintf( '_%s', $smt ), false );
71
}
72
73
$akismet = isset( $submission->akismet )
63
'user_agent', 'url', 'date', 'time', 'post_id', 'post_name',
64
'post_title', 'post_url', 'post_author', 'post_author_email',
65
'site_title', 'site_description', 'site_url', 'site_admin_email',
66
+ 'user_login', 'user_email', 'user_display_name',
67
+ );
68
69
foreach ( $special_mail_tags as $smt ) {
70
+ $tagname = sprintf( '_%s', $smt );
71
+
72
+ $mail_tag = new WPCF7_MailTag(
73
+ sprintf( '[%s]', $tagname ),
74
+ $tagname,
75
+ ''
76
+ );
77
+
78
+ $meta[$smt] = apply_filters( 'wpcf7_special_mail_tags', null,
79
+ $tagname, false, $mail_tag
80
+ );
81
}
82
83
$akismet = isset( $submission->akismet )
modules/number.php CHANGED
@@ -11,7 +11,11 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_number', 10, 0 );
11
12
function wpcf7_add_form_tag_number() {
13
wpcf7_add_form_tag( array( 'number', 'number*', 'range', 'range*' ),
14
- 'wpcf7_number_form_tag_handler', array( 'name-attr' => true ) );
15
}
16
17
function wpcf7_number_form_tag_handler( $tag ) {
@@ -74,7 +78,8 @@ function wpcf7_number_form_tag_handler( $tag ) {
74
75
$html = sprintf(
76
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
77
- sanitize_html_class( $tag->name ), $atts, $validation_error );
78
79
return $html;
80
}
@@ -97,13 +102,13 @@ function wpcf7_number_validation_filter( $result, $tag ) {
97
$min = $tag->get_option( 'min', 'signed_int', true );
98
$max = $tag->get_option( 'max', 'signed_int', true );
99
100
- if ( $tag->is_required() and '' == $value ) {
101
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
102
- } elseif ( '' != $value and ! wpcf7_is_number( $value ) ) {
103
$result->invalidate( $tag, wpcf7_get_message( 'invalid_number' ) );
104
- } elseif ( '' != $value and '' != $min and (float) $value < (float) $min ) {
105
$result->invalidate( $tag, wpcf7_get_message( 'number_too_small' ) );
106
- } elseif ( '' != $value and '' != $max and (float) $max < (float) $value ) {
107
$result->invalidate( $tag, wpcf7_get_message( 'number_too_large' ) );
108
}
109
11
12
function wpcf7_add_form_tag_number() {
13
wpcf7_add_form_tag( array( 'number', 'number*', 'range', 'range*' ),
14
+ 'wpcf7_number_form_tag_handler',
15
+ array(
16
+ 'name-attr' => true,
17
+ )
18
+ );
19
}
20
21
function wpcf7_number_form_tag_handler( $tag ) {
78
79
$html = sprintf(
80
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
81
+ sanitize_html_class( $tag->name ), $atts, $validation_error
82
+ );
83
84
return $html;
85
}
102
$min = $tag->get_option( 'min', 'signed_int', true );
103
$max = $tag->get_option( 'max', 'signed_int', true );
104
105
+ if ( $tag->is_required() and '' === $value ) {
106
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
107
+ } elseif ( '' !== $value and ! wpcf7_is_number( $value ) ) {
108
$result->invalidate( $tag, wpcf7_get_message( 'invalid_number' ) );
109
+ } elseif ( '' !== $value and '' !== $min and (float) $value < (float) $min ) {
110
$result->invalidate( $tag, wpcf7_get_message( 'number_too_small' ) );
111
+ } elseif ( '' !== $value and '' !== $max and (float) $max < (float) $value ) {
112
$result->invalidate( $tag, wpcf7_get_message( 'number_too_large' ) );
113
}
114
modules/quiz.php CHANGED
@@ -73,7 +73,8 @@ function wpcf7_quiz_form_tag_handler( $tag ) {
73
'<span class="wpcf7-form-control-wrap %1$s"><label><span class="wpcf7-quiz-label">%2$s</span> <input %3$s /></label><input type="hidden" name="_wpcf7_quiz_answer_%4$s" value="%5$s" />%6$s</span>',
74
sanitize_html_class( $tag->name ),
75
esc_html( $question ), $atts, $tag->name,
76
- wp_hash( $answer, 'wpcf7_quiz' ), $validation_error );
77
78
return $html;
79
}
@@ -95,7 +96,7 @@ function wpcf7_quiz_validation_filter( $result, $tag ) {
95
? (string) $_POST['_wpcf7_quiz_answer_' . $name]
96
: '';
97
98
- if ( $answer_hash != $expected_hash ) {
99
$result->invalidate( $tag, wpcf7_get_message( 'quiz_answer_not_correct' ) );
100
}
101
73
'<span class="wpcf7-form-control-wrap %1$s"><label><span class="wpcf7-quiz-label">%2$s</span> <input %3$s /></label><input type="hidden" name="_wpcf7_quiz_answer_%4$s" value="%5$s" />%6$s</span>',
74
sanitize_html_class( $tag->name ),
75
esc_html( $question ), $atts, $tag->name,
76
+ wp_hash( $answer, 'wpcf7_quiz' ), $validation_error
77
+ );
78
79
return $html;
80
}
96
? (string) $_POST['_wpcf7_quiz_answer_' . $name]
97
: '';
98
99
+ if ( $answer_hash !== $expected_hash ) {
100
$result->invalidate( $tag, wpcf7_get_message( 'quiz_answer_not_correct' ) );
101
}
102
modules/really-simple-captcha.php CHANGED
@@ -83,7 +83,8 @@ function wpcf7_captchac_form_tag_handler( $tag ) {
83
84
$html = sprintf(
85
'<input type="hidden" name="_wpcf7_captcha_challenge_%1$s" value="%2$s" /><img %3$s />',
86
- $tag->name, esc_attr( $prefix ), $atts );
87
88
return $html;
89
}
@@ -138,7 +139,8 @@ function wpcf7_captchar_form_tag_handler( $tag ) {
138
139
$html = sprintf(
140
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
141
- sanitize_html_class( $tag->name ), $atts, $validation_error );
142
143
return $html;
144
}
@@ -159,12 +161,12 @@ function wpcf7_captcha_validation_filter( $result, $tag ) {
159
$response = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
160
$response = wpcf7_canonicalize( $response );
161
162
- if ( 0 == strlen( $prefix )
163
or ! wpcf7_check_captcha( $prefix, $response ) ) {
164
$result->invalidate( $tag, wpcf7_get_message( 'captcha_not_match' ) );
165
}
166
167
- if ( 0 != strlen( $prefix ) ) {
168
wpcf7_remove_captcha( $prefix );
169
}
170
83
84
$html = sprintf(
85
'<input type="hidden" name="_wpcf7_captcha_challenge_%1$s" value="%2$s" /><img %3$s />',
86
+ $tag->name, esc_attr( $prefix ), $atts
87
+ );
88
89
return $html;
90
}
139
140
$html = sprintf(
141
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
142
+ sanitize_html_class( $tag->name ), $atts, $validation_error
143
+ );
144
145
return $html;
146
}
161
$response = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
162
$response = wpcf7_canonicalize( $response );
163
164
+ if ( 0 === strlen( $prefix )
165
or ! wpcf7_check_captcha( $prefix, $response ) ) {
166
$result->invalidate( $tag, wpcf7_get_message( 'captcha_not_match' ) );
167
}
168
169
+ if ( 0 !== strlen( $prefix ) ) {
170
wpcf7_remove_captcha( $prefix );
171
}
172
modules/recaptcha.php CHANGED
@@ -70,56 +70,63 @@ function wpcf7_recaptcha_onload_script() {
70
71
?>
72
<script type="text/javascript">
73
- ( function( grecaptcha, sitekey, actions ) {
74
-
75
- var wpcf7recaptcha = {
76
-
77
- execute: function( action ) {
78
- grecaptcha.execute(
79
- sitekey,
80
- { action: action }
81
- ).then( function( token ) {
82
- var forms = document.getElementsByTagName( 'form' );
83
-
84
- for ( var i = 0; i < forms.length; i++ ) {
85
- var fields = forms[ i ].getElementsByTagName( 'input' );
86
-
87
- for ( var j = 0; j < fields.length; j++ ) {
88
- var field = fields[ j ];
89
-
90
- if ( 'g-recaptcha-response' === field.getAttribute( 'name' ) ) {
91
- field.setAttribute( 'value', token );
92
- break;
93
- }
94
- }
95
- }
96
- } );
97
- },
98
-
99
- executeOnHomepage: function() {
100
- wpcf7recaptcha.execute( actions[ 'homepage' ] );
101
- },
102
103
- executeOnContactform: function() {
104
- wpcf7recaptcha.execute( actions[ 'contactform' ] );
105
- },
106
107
- };
108
109
- grecaptcha.ready(
110
- wpcf7recaptcha.executeOnHomepage
111
- );
112
113
- document.addEventListener( 'change',
114
- wpcf7recaptcha.executeOnContactform, false
115
- );
116
117
- document.addEventListener( 'wpcf7submit',
118
- wpcf7recaptcha.executeOnHomepage, false
119
- );
120
121
} )(
122
- grecaptcha,
123
'<?php echo esc_js( $service->get_sitekey() ); ?>',
124
<?php echo json_encode( $actions ), "\n"; ?>
125
);
@@ -194,7 +201,7 @@ function wpcf7_upgrade_recaptcha_v2_v3( $new_ver, $old_ver ) {
194
195
$service = WPCF7_RECAPTCHA::get_instance();
196
197
- if ( ! $service->is_active() ) {
198
return;
199
}
200
@@ -419,7 +426,7 @@ class WPCF7_RECAPTCHA extends WPCF7_Service {
419
$url = menu_page_url( 'wpcf7-integration', false );
420
$url = add_query_arg( array( 'service' => 'recaptcha' ), $url );
421
422
- if ( ! empty( $args) ) {
423
$url = add_query_arg( $args, $url );
424
}
425
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
);
201
202
$service = WPCF7_RECAPTCHA::get_instance();
203
204
+ if ( ! $service->is_active() or $service->get_global_sitekey() ) {
205
return;
206
}
207
426
$url = menu_page_url( 'wpcf7-integration', false );
427
$url = add_query_arg( array( 'service' => 'recaptcha' ), $url );
428
429
+ if ( ! empty( $args ) ) {
430
$url = add_query_arg( $args, $url );
431
}
432
modules/response.php CHANGED
@@ -8,8 +8,12 @@
8
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_response', 10, 0 );
9
10
function wpcf7_add_form_tag_response() {
11
- wpcf7_add_form_tag( 'response', 'wpcf7_response_form_tag_handler',
12
- array( 'display-block' => true ) );
13
}
14
15
function wpcf7_response_form_tag_handler( $tag ) {
8
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_response', 10, 0 );
9
10
function wpcf7_add_form_tag_response() {
11
+ wpcf7_add_form_tag( 'response',
12
+ 'wpcf7_response_form_tag_handler',
13
+ array(
14
+ 'display-block' => true,
15
+ )
16
+ );
17
}
18
19
function wpcf7_response_form_tag_handler( $tag ) {
modules/select.php CHANGED
@@ -112,7 +112,8 @@ function wpcf7_select_form_tag_handler( $tag ) {
112
113
$html = sprintf(
114
'<span class="wpcf7-form-control-wrap %1$s"><select %2$s>%3$s</select>%4$s</span>',
115
- sanitize_html_class( $tag->name ), $atts, $html, $validation_error );
116
117
return $html;
118
}
112
113
$html = sprintf(
114
'<span class="wpcf7-form-control-wrap %1$s"><select %2$s>%3$s</select>%4$s</span>',
115
+ sanitize_html_class( $tag->name ), $atts, $html, $validation_error
116
+ );
117
118
return $html;
119
}
modules/text.php CHANGED
@@ -14,7 +14,11 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_text', 10, 0 );
14
function wpcf7_add_form_tag_text() {
15
wpcf7_add_form_tag(
16
array( 'text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*' ),
17
- 'wpcf7_text_form_tag_handler', array( 'name-attr' => true ) );
18
}
19
20
function wpcf7_text_form_tag_handler( $tag ) {
@@ -88,7 +92,8 @@ function wpcf7_text_form_tag_handler( $tag ) {
88
89
$html = sprintf(
90
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
91
- sanitize_html_class( $tag->name ), $atts, $validation_error );
92
93
return $html;
94
}
@@ -113,31 +118,31 @@ function wpcf7_text_validation_filter( $result, $tag ) {
113
: '';
114
115
if ( 'text' == $tag->basetype ) {
116
- if ( $tag->is_required() and '' == $value ) {
117
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
118
}
119
}
120
121
if ( 'email' == $tag->basetype ) {
122
- if ( $tag->is_required() and '' == $value ) {
123
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
124
- } elseif ( '' != $value and ! wpcf7_is_email( $value ) ) {
125
$result->invalidate( $tag, wpcf7_get_message( 'invalid_email' ) );
126
}
127
}
128
129
if ( 'url' == $tag->basetype ) {
130
- if ( $tag->is_required() and '' == $value ) {
131
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
132
- } elseif ( '' != $value and ! wpcf7_is_url( $value ) ) {
133
$result->invalidate( $tag, wpcf7_get_message( 'invalid_url' ) );
134
}
135
}
136
137
if ( 'tel' == $tag->basetype ) {
138
- if ( $tag->is_required() and '' == $value ) {
139
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
140
- } elseif ( '' != $value and ! wpcf7_is_tel( $value ) ) {
141
$result->invalidate( $tag, wpcf7_get_message( 'invalid_tel' ) );
142
}
143
}
14
function wpcf7_add_form_tag_text() {
15
wpcf7_add_form_tag(
16
array( 'text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*' ),
17
+ 'wpcf7_text_form_tag_handler',
18
+ array(
19
+ 'name-attr' => true,
20
+ )
21
+ );
22
}
23
24
function wpcf7_text_form_tag_handler( $tag ) {
92
93
$html = sprintf(
94
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
95
+ sanitize_html_class( $tag->name ), $atts, $validation_error
96
+ );
97
98
return $html;
99
}
118
: '';
119
120
if ( 'text' == $tag->basetype ) {
121
+ if ( $tag->is_required() and '' === $value ) {
122
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
123
}
124
}
125
126
if ( 'email' == $tag->basetype ) {
127
+ if ( $tag->is_required() and '' === $value ) {
128
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
129
+ } elseif ( '' !== $value and ! wpcf7_is_email( $value ) ) {
130
$result->invalidate( $tag, wpcf7_get_message( 'invalid_email' ) );
131
}
132
}
133
134
if ( 'url' == $tag->basetype ) {
135
+ if ( $tag->is_required() and '' === $value ) {
136
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
137
+ } elseif ( '' !== $value and ! wpcf7_is_url( $value ) ) {
138
$result->invalidate( $tag, wpcf7_get_message( 'invalid_url' ) );
139
}
140
}
141
142
if ( 'tel' == $tag->basetype ) {
143
+ if ( $tag->is_required() and '' === $value ) {
144
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
145
+ } elseif ( '' !== $value and ! wpcf7_is_tel( $value ) ) {
146
$result->invalidate( $tag, wpcf7_get_message( 'invalid_tel' ) );
147
}
148
}
modules/textarea.php CHANGED
@@ -9,7 +9,8 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_textarea', 10, 0 );
9
10
function wpcf7_add_form_tag_textarea() {
11
wpcf7_add_form_tag( array( 'textarea', 'textarea*' ),
12
- 'wpcf7_textarea_form_tag_handler', array( 'name-attr' => true ) );
13
}
14
15
function wpcf7_textarea_form_tag_handler( $tag ) {
@@ -75,7 +76,8 @@ function wpcf7_textarea_form_tag_handler( $tag ) {
75
$html = sprintf(
76
'<span class="wpcf7-form-control-wrap %1$s"><textarea %2$s>%3$s</textarea>%4$s</span>',
77
sanitize_html_class( $tag->name ), $atts,
78
- esc_textarea( $value ), $validation_error );
79
80
return $html;
81
}
@@ -94,7 +96,7 @@ function wpcf7_textarea_validation_filter( $result, $tag ) {
94
95
$value = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
96
97
- if ( $tag->is_required() and '' == $value ) {
98
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
99
}
100
9
10
function wpcf7_add_form_tag_textarea() {
11
wpcf7_add_form_tag( array( 'textarea', 'textarea*' ),
12
+ 'wpcf7_textarea_form_tag_handler', array( 'name-attr' => true )
13
+ );
14
}
15
16
function wpcf7_textarea_form_tag_handler( $tag ) {
76
$html = sprintf(
77
'<span class="wpcf7-form-control-wrap %1$s"><textarea %2$s>%3$s</textarea>%4$s</span>',
78
sanitize_html_class( $tag->name ), $atts,
79
+ esc_textarea( $value ), $validation_error
80
+ );
81
82
return $html;
83
}
96
97
$value = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
98
99
+ if ( $tag->is_required() and '' === $value ) {
100
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
101
}
102
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: 4.9
6
Tested up to: 5.4
7
- Stable tag: 5.1.7
8
License: GPLv2 or later
9
License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
@@ -75,6 +75,15 @@ 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.7 =
79
80
* CSS: Adds an explicit LTR direction style rule for code inputs.
4
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
5
Requires at least: 4.9
6
Tested up to: 5.4
7
+ Stable tag: 5.1.8
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.1.8 =
79
+
80
+ * reCAPTCHA: Shows no warning on upgrading from v2 if the global sitekey is defined.
81
+ * reCAPTCHA: Improves the frontend JavaScript coding.
82
+ * Accessibility: Improves the response message markup.
83
+ * Fixes the regular expression pattern in `wpcf7_is_tel()`.
84
+ * Fixed: Character count was not reset after a successful submission.
85
+ * Fixed: The fourth parameter of the `wpcf7_special_mail_tags` filter hook was not correctly set.
86
+
87
= 5.1.7 =
88
89
* CSS: Adds an explicit LTR direction style rule for code inputs.
settings.php CHANGED
@@ -149,7 +149,7 @@ function wpcf7_install() {
149
150
WPCF7::update_option( 'bulk_validate',
151
array(
152
- 'timestamp' => current_time( 'timestamp' ),
153
'version' => WPCF7_VERSION,
154
'count_valid' => 1,
155
'count_invalid' => 0,
149
150
WPCF7::update_option( 'bulk_validate',
151
array(
152
+ 'timestamp' => time(),
153
'version' => WPCF7_VERSION,
154
'count_valid' => 1,
155
'count_invalid' => 0,
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.1.7
11
*/
12
13
- define( 'WPCF7_VERSION', '5.1.7' );
14
15
define( 'WPCF7_REQUIRED_WP_VERSION', '4.9' );
16
7
Author URI: https://ideasilo.wordpress.com/
8
Text Domain: contact-form-7
9
Domain Path: /languages/
10
+ Version: 5.1.8
11
*/
12
13
+ define( 'WPCF7_VERSION', '5.1.8' );
14
15
define( 'WPCF7_REQUIRED_WP_VERSION', '4.9' );
16