Contact Form 7 - Version 4.5

Version Description

  • The default contact form template is revised.
  • reCAPTCHA: Run grecaptcha.reset() after a submission.
  • The autocomplete option for form-tags and wpcf7_form_autocomplete filter hook are introduced to manage autocomplete attribute.
  • The config validator is revised. The wpcf7_config_validator_validate action hook is introduced to allow 3rd-party to cut in.
  • A bug in character count form-tag is fixed.
  • Language Packs: Language files for Danish (da_DK), Polish (pl_PL), and Czech (cs_CZ) have been removed from the plugin package.
Download this release

Release Info

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

Code changes from version 4.4.2 to 4.5

admin/admin.php CHANGED
@@ -3,6 +3,7 @@
3
require_once WPCF7_PLUGIN_DIR . '/admin/includes/admin-functions.php';
4
require_once WPCF7_PLUGIN_DIR . '/admin/includes/help-tabs.php';
5
require_once WPCF7_PLUGIN_DIR . '/admin/includes/tag-generator.php';
6
7
add_action( 'admin_init', 'wpcf7_admin_init' );
8
@@ -170,12 +171,13 @@ function wpcf7_load_contact_form_admin() {
170
'count_invalid' => 0 );
171
172
foreach ( $contact_forms as $contact_form ) {
173
- $contact_form->validate_configuration();
174
175
- if ( $contact_form->get_config_errors() ) {
176
- $result['count_invalid'] += 1;
177
- } else {
178
$result['count_valid'] += 1;
179
}
180
}
181
@@ -245,10 +247,34 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
245
array( 'jquery', 'jquery-ui-tabs' ),
246
WPCF7_VERSION, true );
247
248
- wp_localize_script( 'wpcf7-admin', '_wpcf7', array(
249
'pluginUrl' => wpcf7_plugin_url(),
250
- 'saveAlert' => __( "The changes you made will be lost if you navigate away from this page.", 'contact-form-7' ),
251
- 'activeTab' => isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : 0 ) );
252
253
add_thickbox();
254
@@ -293,6 +319,8 @@ function wpcf7_admin_management_page() {
293
}
294
?></h1>
295
296
<?php do_action( 'wpcf7_admin_notices' ); ?>
297
298
<form method="get" action="">
@@ -367,6 +395,7 @@ function wpcf7_admin_integration_page() {
367
368
<h1><?php echo esc_html( __( 'Integration with Other Services', 'contact-form-7' ) ); ?></h1>
369
370
<?php do_action( 'wpcf7_admin_notices' ); ?>
371
372
<?php
@@ -444,7 +473,7 @@ function wpcf7_plugin_action_links( $links, $file ) {
444
return $links;
445
}
446
447
- add_action( 'wpcf7_admin_notices', 'wpcf7_old_wp_version_error', 2 );
448
449
function wpcf7_old_wp_version_error() {
450
$wp_version = get_bloginfo( 'version' );
@@ -454,92 +483,13 @@ function wpcf7_old_wp_version_error() {
454
}
455
456
?>
457
- <div class="notice notice-error is-dismissible">
458
<p><?php echo sprintf( __( '<strong>Contact Form 7 %1$s requires WordPress %2$s or higher.</strong> Please <a href="%3$s">update WordPress</a> first.', 'contact-form-7' ), WPCF7_VERSION, WPCF7_REQUIRED_WP_VERSION, admin_url( 'update-core.php' ) ); ?></p>
459
</div>
460
<?php
461
}
462
463
- add_action( 'wpcf7_admin_notices', 'wpcf7_welcome_panel', 4 );
464
-
465
- function wpcf7_welcome_panel() {
466
- global $plugin_page;
467
-
468
- if ( 'wpcf7' != $plugin_page || ! empty( $_GET['post'] ) ) {
469
- return;
470
- }
471
-
472
- $classes = 'welcome-panel';
473
-
474
- $vers = (array) get_user_meta( get_current_user_id(),
475
- 'wpcf7_hide_welcome_panel_on', true );
476
-
477
- if ( wpcf7_version_grep( wpcf7_version( 'only_major=1' ), $vers ) ) {
478
- $classes .= ' hidden';
479
- }
480
-
481
- ?>
482
- <div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
483
- <?php wp_nonce_field( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
484
- <a class="welcome-panel-close" href="<?php echo esc_url( menu_page_url( 'wpcf7', false ) ); ?>"><?php echo esc_html( __( 'Dismiss', 'contact-form-7' ) ); ?></a>
485
-
486
- <div class="welcome-panel-content">
487
- <div class="welcome-panel-column-container">
488
- <div class="welcome-panel-column">
489
- <h3><?php echo esc_html( __( 'Contact Form 7 Needs Your Support', 'contact-form-7' ) ); ?></h3>
490
- <p class="message"><?php echo esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you. If you enjoy using Contact Form 7 and find it useful, please consider making a donation.", 'contact-form-7' ) ); ?></p>
491
- <p><?php echo wpcf7_link( __( 'http://contactform7.com/donate/', 'contact-form-7' ), __( 'Donate', 'contact-form-7' ), array( 'class' => 'button button-primary' ) ); ?></p>
492
- </div>
493
-
494
- <div class="welcome-panel-column">
495
- <h3><?php echo esc_html( __( 'Get Started', 'contact-form-7' ) ); ?></h3>
496
- <ul>
497
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/getting-started-with-contact-form-7/', 'contact-form-7' ), __( 'Getting Started with Contact Form 7', 'contact-form-7' ) ); ?></li>
498
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/admin-screen/', 'contact-form-7' ), __( 'Admin Screen', 'contact-form-7' ) ); ?></li>
499
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/tag-syntax/', 'contact-form-7' ), __( 'How Tags Work', 'contact-form-7' ) ); ?></li>
500
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/setting-up-mail/', 'contact-form-7' ), __( 'Setting Up Mail', 'contact-form-7' ) ); ?></li>
501
- </ul>
502
- </div>
503
-
504
- <div class="welcome-panel-column">
505
- <h3><?php echo esc_html( __( 'Did You Know?', 'contact-form-7' ) ); ?></h3>
506
- <ul>
507
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), __( 'Spam Filtering with Akismet', 'contact-form-7' ) ); ?></li>
508
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ), __( 'Save Messages with Flamingo', 'contact-form-7' ) ); ?></li>
509
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/selectable-recipient-with-pipes/', 'contact-form-7' ), __( 'Selectable Recipient with Pipes', 'contact-form-7' ) ); ?></li>
510
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/tracking-form-submissions-with-google-analytics/', 'contact-form-7' ), __( 'Tracking with Google Analytics', 'contact-form-7' ) ); ?></li>
511
- </ul>
512
- </div>
513
- </div>
514
- </div>
515
- </div>
516
- <?php
517
- }
518
-
519
- add_action( 'wp_ajax_wpcf7-update-welcome-panel', 'wpcf7_admin_ajax_welcome_panel' );
520
-
521
- function wpcf7_admin_ajax_welcome_panel() {
522
- check_ajax_referer( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce' );
523
-
524
- $vers = get_user_meta( get_current_user_id(),
525
- 'wpcf7_hide_welcome_panel_on', true );
526
-
527
- if ( empty( $vers ) || ! is_array( $vers ) ) {
528
- $vers = array();
529
- }
530
-
531
- if ( empty( $_POST['visible'] ) ) {
532
- $vers[] = WPCF7_VERSION;
533
- }
534
-
535
- $vers = array_unique( $vers );
536
-
537
- update_user_meta( get_current_user_id(), 'wpcf7_hide_welcome_panel_on', $vers );
538
-
539
- wp_die( 1 );
540
- }
541
-
542
- add_action( 'wpcf7_admin_notices', 'wpcf7_not_allowed_to_edit' );
543
544
function wpcf7_not_allowed_to_edit() {
545
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
@@ -556,11 +506,11 @@ function wpcf7_not_allowed_to_edit() {
556
'contact-form-7' );
557
558
echo sprintf(
559
- '<div class="notice notice-warning is-dismissible"><p>%s</p></div>',
560
esc_html( $message ) );
561
}
562
563
- add_action( 'wpcf7_admin_notices', 'wpcf7_notice_config_errors' );
564
565
function wpcf7_notice_config_errors() {
566
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
@@ -572,23 +522,29 @@ function wpcf7_notice_config_errors() {
572
return;
573
}
574
575
- if ( $config_errors = $contact_form->get_config_errors() ) {
576
$message = sprintf(
577
_n(
578
- "This contact form has a configuration error.",
579
- "This contact form has %s configuration errors.",
580
- count( $config_errors ), 'contact-form-7' ),
581
- number_format_i18n( count( $config_errors ) ) );
582
583
$link = wpcf7_link(
584
- __( 'http://contactform7.com/configuration-errors/', 'contact-form-7' ),
585
- __( 'How to Resolve Configuration Errors', 'contact-form-7' ) );
586
587
- echo sprintf( '<div class="notice notice-warning is-dismissible"><p>%s &raquo; %s</p></div>', esc_html( $message ), $link );
588
}
589
}
590
591
- add_action( 'admin_notices', 'wpcf7_notice_bulk_validate_config' );
592
593
function wpcf7_notice_bulk_validate_config() {
594
if ( ! wpcf7_validate_configuration()
@@ -613,5 +569,6 @@ function wpcf7_notice_bulk_validate_config() {
613
614
$message = __( "Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.", 'contact-form-7' );
615
616
- echo sprintf( '<div class="notice notice-warning is-dismissible"><p>%s &raquo; %s</p></div>', esc_html( $message ), $link );
617
}
3
require_once WPCF7_PLUGIN_DIR . '/admin/includes/admin-functions.php';
4
require_once WPCF7_PLUGIN_DIR . '/admin/includes/help-tabs.php';
5
require_once WPCF7_PLUGIN_DIR . '/admin/includes/tag-generator.php';
6
+ require_once WPCF7_PLUGIN_DIR . '/admin/includes/welcome-panel.php';
7
8
add_action( 'admin_init', 'wpcf7_admin_init' );
9
171
'count_invalid' => 0 );
172
173
foreach ( $contact_forms as $contact_form ) {
174
+ $config_validator = new WPCF7_ConfigValidator( $contact_form );
175
+ $config_validator->validate();
176
177
+ if ( $config_validator->is_valid() ) {
178
$result['count_valid'] += 1;
179
+ } else {
180
+ $result['count_invalid'] += 1;
181
}
182
}
183
247
array( 'jquery', 'jquery-ui-tabs' ),
248
WPCF7_VERSION, true );
249
250
+ $args = array(
251
'pluginUrl' => wpcf7_plugin_url(),
252
+ 'saveAlert' => __(
253
+ "The changes you made will be lost if you navigate away from this page.",
254
+ 'contact-form-7' ),
255
+ 'activeTab' => isset( $_GET['active-tab'] )
256
+ ? (int) $_GET['active-tab'] : 0,
257
+ 'howToCorrectLink' => __( "How to correct this?", 'contact-form-7' ),
258
+ 'configErrors' => array() );
259
+
260
+ if ( ( $post = wpcf7_get_current_contact_form() )
261
+ && current_user_can( 'wpcf7_edit_contact_form', $post->id() )
262
+ && wpcf7_validate_configuration() ) {
263
+ $config_validator = new WPCF7_ConfigValidator( $post );
264
+ $error_messages = $config_validator->collect_error_messages();
265
+
266
+ foreach ( $error_messages as $section => $errors ) {
267
+ $args['configErrors'][$section] = array();
268
+
269
+ foreach ( $errors as $error ) {
270
+ $args['configErrors'][$section][] = array(
271
+ 'message' => esc_html( $error['message'] ),
272
+ 'link' => esc_url( $error['link'] ) );
273
+ }
274
+ }
275
+ }
276
+
277
+ wp_localize_script( 'wpcf7-admin', '_wpcf7', $args );
278
279
add_thickbox();
280
319
}
320
?></h1>
321
322
+ <?php do_action( 'wpcf7_admin_warnings' ); ?>
323
+ <?php wpcf7_welcome_panel(); ?>
324
<?php do_action( 'wpcf7_admin_notices' ); ?>
325
326
<form method="get" action="">
395
396
<h1><?php echo esc_html( __( 'Integration with Other Services', 'contact-form-7' ) ); ?></h1>
397
398
+ <?php do_action( 'wpcf7_admin_warnings' ); ?>
399
<?php do_action( 'wpcf7_admin_notices' ); ?>
400
401
<?php
473
return $links;
474
}
475
476
+ add_action( 'wpcf7_admin_warnings', 'wpcf7_old_wp_version_error' );
477
478
function wpcf7_old_wp_version_error() {
479
$wp_version = get_bloginfo( 'version' );
483
}
484
485
?>
486
+ <div class="notice notice-warning">
487
<p><?php echo sprintf( __( '<strong>Contact Form 7 %1$s requires WordPress %2$s or higher.</strong> Please <a href="%3$s">update WordPress</a> first.', 'contact-form-7' ), WPCF7_VERSION, WPCF7_REQUIRED_WP_VERSION, admin_url( 'update-core.php' ) ); ?></p>
488
</div>
489
<?php
490
}
491
492
+ add_action( 'wpcf7_admin_warnings', 'wpcf7_not_allowed_to_edit' );
493
494
function wpcf7_not_allowed_to_edit() {
495
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
506
'contact-form-7' );
507
508
echo sprintf(
509
+ '<div class="notice notice-warning"><p>%s</p></div>',
510
esc_html( $message ) );
511
}
512
513
+ add_action( 'wpcf7_admin_misc_pub_section', 'wpcf7_notice_config_errors' );
514
515
function wpcf7_notice_config_errors() {
516
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
522
return;
523
}
524
525
+ $config_validator = new WPCF7_ConfigValidator( $contact_form );
526
+
527
+ if ( $count_errors = $config_validator->count_errors() ) {
528
$message = sprintf(
529
_n(
530
+ '%s configuration error found',
531
+ '%s configuration errors found',
532
+ $count_errors, 'contact-form-7' ),
533
+ number_format_i18n( $count_errors ) );
534
535
$link = wpcf7_link(
536
+ __( 'http://contactform7.com/configuration-validator-faq/',
537
+ 'contact-form-7' ),
538
+ __( "What's this?", 'contact-form-7' ),
539
+ array( 'class' => 'external' ) );
540
541
+ echo sprintf(
542
+ '<div class="misc-pub-section warning">%1$s<br />%2$s</div>',
543
+ $message, $link );
544
}
545
}
546
547
+ add_action( 'wpcf7_admin_warnings', 'wpcf7_notice_bulk_validate_config', 5 );
548
549
function wpcf7_notice_bulk_validate_config() {
550
if ( ! wpcf7_validate_configuration()
569
570
$message = __( "Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.", 'contact-form-7' );
571
572
+ echo sprintf( '<div class="notice notice-warning"><p>%s &raquo; %s</p></div>',
573
+ esc_html( $message ), $link );
574
}
admin/css/styles.css CHANGED
@@ -56,12 +56,51 @@ span.shortcode > input {
56
color: #23282d;
57
}
58
59
- div.config-error, span.config-error {
60
color: #d00;
61
font-style: normal;
62
font-size: 13px;
63
}
64
65
/*
66
* Tabs
67
*/
56
color: #23282d;
57
}
58
59
+ #misc-publishing-actions .misc-pub-section::before {
60
+ content: "\f488";
61
+ -moz-osx-font-smoothing: grayscale;
62
+ display: inline-block;
63
+ font: 20px/1 dashicons;
64
+ left: -1px;
65
+ padding: 0 2px 0 0;
66
+ position: relative;
67
+ text-decoration: none !important;
68
+ top: 0;
69
+ vertical-align: top;
70
+ color: #82878c;
71
+ }
72
+
73
+ #misc-publishing-actions .misc-pub-section.warning::before {
74
+ content: "\f534";
75
+ }
76
+
77
+ #misc-publishing-actions .misc-pub-section.warning a.external {
78
+ font-style: italic;
79
+ }
80
+
81
+ div.config-error, span.config-error, ul.config-error {
82
color: #d00;
83
font-style: normal;
84
font-size: 13px;
85
}
86
87
+ ul.config-error {
88
+ margin: 0;
89
+ }
90
+
91
+ ul.config-error li {
92
+ padding: 0 4px;
93
+ margin: 0;
94
+ }
95
+
96
+ ul.config-error li a.external {
97
+ font-style: italic;
98
+ }
99
+
100
+ [data-config-field][aria-invalid="true"] {
101
+ border-color: #d00;
102
+ }
103
+
104
/*
105
* Tabs
106
*/
admin/edit-contact-form.php CHANGED
@@ -43,6 +43,7 @@ function wpcf7_admin_save_button( $post_id ) {
43
}
44
?></h1>
45
46
<?php do_action( 'wpcf7_admin_notices' ); ?>
47
48
<?php
@@ -132,6 +133,10 @@ if ( $post ) :
132
<?php endif; ?>
133
</div><!-- #minor-publishing-actions -->
134
135
<div id="major-publishing-actions">
136
137
<?php
43
}
44
?></h1>
45
46
+ <?php do_action( 'wpcf7_admin_warnings' ); ?>
47
<?php do_action( 'wpcf7_admin_notices' ); ?>
48
49
<?php
133
<?php endif; ?>
134
</div><!-- #minor-publishing-actions -->
135
136
+ <div id="misc-publishing-actions">
137
+ <?php do_action( 'wpcf7_admin_misc_pub_section', $post_id ); ?>
138
+ </div><!-- #misc-publishing-actions -->
139
+
140
<div id="major-publishing-actions">
141
142
<?php
admin/includes/admin-functions.php CHANGED
@@ -158,7 +158,8 @@ function wpcf7_save_contact_form( $post_id = -1 ) {
158
$post_id = $contact_form->save();
159
160
if ( wpcf7_validate_configuration() ) {
161
- $contact_form->validate_configuration();
162
}
163
164
return $post_id;
158
$post_id = $contact_form->save();
159
160
if ( wpcf7_validate_configuration() ) {
161
+ $config_validator = new WPCF7_ConfigValidator( $contact_form );
162
+ $config_validator->validate();
163
}
164
165
return $post_id;
admin/includes/class-contact-forms-list-table.php CHANGED
@@ -110,17 +110,20 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
110
$output = sprintf( '<strong>%s</strong>', $output );
111
112
if ( wpcf7_validate_configuration()
113
- && current_user_can( 'wpcf7_edit_contact_form', $item->id() )
114
- && $config_errors = $item->get_config_errors() ) {
115
- $error_notice = sprintf(
116
- _n(
117
- '%s configuration error found',
118
- '%s configuration errors found',
119
- count( $config_errors ), 'contact-form-7' ),
120
- number_format_i18n( count( $config_errors ) ) );
121
- $output .= sprintf(
122
- '<div class="config-error">%s</div>',
123
- $error_notice );
124
}
125
126
$actions = array(
110
$output = sprintf( '<strong>%s</strong>', $output );
111
112
if ( wpcf7_validate_configuration()
113
+ && current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
114
+ $config_validator = new WPCF7_ConfigValidator( $item );
115
+
116
+ if ( $count_errors = $config_validator->count_errors() ) {
117
+ $error_notice = sprintf(
118
+ _n(
119
+ '%s configuration error found',
120
+ '%s configuration errors found',
121
+ $count_errors, 'contact-form-7' ),
122
+ number_format_i18n( $count_errors ) );
123
+ $output .= sprintf(
124
+ '<div class="config-error">%s</div>',
125
+ $error_notice );
126
+ }
127
}
128
129
$actions = array(
admin/includes/editor.php CHANGED
@@ -49,7 +49,7 @@ function wpcf7_editor_panel_form( $post ) {
49
$tag_generator->print_buttons();
50
?>
51
52
- <textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="24" class="large-text code"><?php echo esc_textarea( $post->prop( 'form' ) ); ?></textarea>
53
<?php
54
}
55
@@ -79,8 +79,6 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
79
'subject' => '', 'body' => '', 'additional_headers' => '',
80
'attachments' => '', 'use_html' => false, 'exclude_blank' => false ) );
81
82
- $do_validate = wpcf7_validate_configuration();
83
-
84
?>
85
<div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
86
<h2><?php echo esc_html( $args['title'] ); ?></h2>
@@ -104,12 +102,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
104
<label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
105
</th>
106
<td>
107
- <?php $config_error = $post->config_error(
108
- sprintf( '%s.recipient', $args['name'] ) ); ?>
109
- <input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>-recipient" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?> />
110
- <?php if ( $do_validate && $config_error ) {
111
- echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
112
- } ?>
113
</td>
114
</tr>
115
@@ -118,12 +111,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
118
<label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
119
</th>
120
<td>
121
- <?php $config_error = $post->config_error(
122
- sprintf( '%s.sender', $args['name'] ) ); ?>
123
- <input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>-sender" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?> />
124
- <?php if ( $do_validate && $config_error ) {
125
- echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
126
- } ?>
127
</td>
128
</tr>
129
@@ -132,12 +120,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
132
<label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
133
</th>
134
<td>
135
- <?php $config_error = $post->config_error(
136
- sprintf( '%s.subject', $args['name'] ) ); ?>
137
- <input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>-subject" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?> />
138
- <?php if ( $do_validate && $config_error ) {
139
- echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
140
- } ?>
141
</td>
142
</tr>
143
@@ -146,12 +129,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
146
<label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional Headers', 'contact-form-7' ) ); ?></label>
147
</th>
148
<td>
149
- <?php $config_error = $post->config_error(
150
- sprintf( '%s.additional_headers', $args['name'] ) ); ?>
151
- <textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>-additional-headers" cols="100" rows="4" class="large-text code"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?>><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
152
- <?php if ( $do_validate && $config_error ) {
153
- echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
154
- } ?>
155
</td>
156
</tr>
157
@@ -160,12 +138,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
160
<label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message Body', 'contact-form-7' ) ); ?></label>
161
</th>
162
<td>
163
- <?php $config_error = $post->config_error(
164
- sprintf( '%s.body', $args['name'] ) ); ?>
165
- <textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>-body" cols="100" rows="18" class="large-text code"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?>><?php echo esc_textarea( $mail['body'] ); ?></textarea>
166
- <?php if ( $do_validate && $config_error ) {
167
- echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
168
- } ?>
169
170
<p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>-exclude-blank" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
171
@@ -178,7 +151,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
178
<label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File Attachments', 'contact-form-7' ) ); ?></label>
179
</th>
180
<td>
181
- <textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>-attachments" cols="100" rows="4" class="large-text code"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
182
</td>
183
</tr>
184
</tbody>
@@ -196,8 +169,6 @@ function wpcf7_editor_panel_messages( $post ) {
196
unset( $messages['captcha_not_match'] );
197
}
198
199
- $do_validate = wpcf7_validate_configuration();
200
-
201
?>
202
<h2><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h2>
203
<fieldset>
@@ -207,18 +178,10 @@ function wpcf7_editor_panel_messages( $post ) {
207
foreach ( $messages as $key => $arr ) {
208
$field_name = 'wpcf7-message-' . strtr( $key, '_', '-' );
209
210
- $config_error = $do_validate
211
- ? $post->config_error( sprintf( 'messages.%s', $key ) ) : '';
212
-
213
?>
214
<p class="description">
215
<label for="<?php echo $field_name; ?>"><?php echo esc_html( $arr['description'] ); ?><br />
216
- <input type="text" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>"<?php echo $config_error ? ' aria-invalid="true"' : ''; ?> />
217
- <?php
218
- if ( $config_error ) {
219
- echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
220
- }
221
- ?>
222
</label>
223
</p>
224
<?php
@@ -239,7 +202,7 @@ function wpcf7_editor_panel_additional_settings( $post ) {
239
<h2><?php echo esc_html( __( 'Additional Settings', 'contact-form-7' ) ); ?></h2>
240
<fieldset>
241
<legend><?php echo $description; ?></legend>
242
- <textarea id="wpcf7-additional-settings" name="wpcf7-additional-settings" cols="100" rows="8" class="large-text"><?php echo esc_textarea( $post->prop( 'additional_settings' ) ); ?></textarea>
243
</fieldset>
244
<?php
245
}
49
$tag_generator->print_buttons();
50
?>
51
52
+ <textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="24" class="large-text code" data-config-field="form.body"><?php echo esc_textarea( $post->prop( 'form' ) ); ?></textarea>
53
<?php
54
}
55
79
'subject' => '', 'body' => '', 'additional_headers' => '',
80
'attachments' => '', 'use_html' => false, 'exclude_blank' => false ) );
81
82
?>
83
<div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
84
<h2><?php echo esc_html( $args['title'] ); ?></h2>
102
<label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
103
</th>
104
<td>
105
+ <input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>-recipient" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" data-config-field="<?php echo sprintf( '%s.recipient', esc_attr( $args['name'] ) ); ?>" />
106
</td>
107
</tr>
108
111
<label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
112
</th>
113
<td>
114
+ <input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>-sender" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" data-config-field="<?php echo sprintf( '%s.sender', esc_attr( $args['name'] ) ); ?>" />
115
</td>
116
</tr>
117
120
<label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
121
</th>
122
<td>
123
+ <input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>-subject" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" data-config-field="<?php echo sprintf( '%s.subject', esc_attr( $args['name'] ) ); ?>" />
124
</td>
125
</tr>
126
129
<label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional Headers', 'contact-form-7' ) ); ?></label>
130
</th>
131
<td>
132
+ <textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>-additional-headers" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.additional_headers', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
133
</td>
134
</tr>
135
138
<label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message Body', 'contact-form-7' ) ); ?></label>
139
</th>
140
<td>
141
+ <textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>-body" cols="100" rows="18" class="large-text code" data-config-field="<?php echo sprintf( '%s.body', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
142
143
<p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>-exclude-blank" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
144
151
<label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File Attachments', 'contact-form-7' ) ); ?></label>
152
</th>
153
<td>
154
+ <textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>-attachments" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.attachments', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
155
</td>
156
</tr>
157
</tbody>
169
unset( $messages['captcha_not_match'] );
170
}
171
172
?>
173
<h2><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h2>
174
<fieldset>
178
foreach ( $messages as $key => $arr ) {
179
$field_name = 'wpcf7-message-' . strtr( $key, '_', '-' );
180
181
?>
182
<p class="description">
183
<label for="<?php echo $field_name; ?>"><?php echo esc_html( $arr['description'] ); ?><br />
184
+ <input type="text" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>" data-config-field="<?php echo sprintf( 'messages.%s', esc_attr( $key ) ); ?>" />
185
</label>
186
</p>
187
<?php
202
<h2><?php echo esc_html( __( 'Additional Settings', 'contact-form-7' ) ); ?></h2>
203
<fieldset>
204
<legend><?php echo $description; ?></legend>
205
+ <textarea id="wpcf7-additional-settings" name="wpcf7-additional-settings" cols="100" rows="8" class="large-text" data-config-field="additional_settings.body"><?php echo esc_textarea( $post->prop( 'additional_settings' ) ); ?></textarea>
206
</fieldset>
207
<?php
208
}
admin/includes/welcome-panel.php ADDED
@@ -0,0 +1,72 @@
1
+ <?php
2
+
3
+ function wpcf7_welcome_panel() {
4
+ $classes = 'welcome-panel';
5
+
6
+ $vers = (array) get_user_meta( get_current_user_id(),
7
+ 'wpcf7_hide_welcome_panel_on', true );
8
+
9
+ if ( wpcf7_version_grep( wpcf7_version( 'only_major=1' ), $vers ) ) {
10
+ $classes .= ' hidden';
11
+ }
12
+
13
+ ?>
14
+ <div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
15
+ <?php wp_nonce_field( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
16
+ <a class="welcome-panel-close" href="<?php echo esc_url( menu_page_url( 'wpcf7', false ) ); ?>"><?php echo esc_html( __( 'Dismiss', 'contact-form-7' ) ); ?></a>
17
+
18
+ <div class="welcome-panel-content">
19
+ <div class="welcome-panel-column-container">
20
+ <div class="welcome-panel-column">
21
+ <h3><?php echo esc_html( __( 'Contact Form 7 Needs Your Support', 'contact-form-7' ) ); ?></h3>
22
+ <p class="message"><?php echo esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you. If you enjoy using Contact Form 7 and find it useful, please consider making a donation.", 'contact-form-7' ) ); ?></p>
23
+ <p><?php echo wpcf7_link( __( 'http://contactform7.com/donate/', 'contact-form-7' ), __( 'Donate', 'contact-form-7' ), array( 'class' => 'button button-primary' ) ); ?></p>
24
+ </div>
25
+
26
+ <div class="welcome-panel-column">
27
+ <h3><?php echo esc_html( __( 'Get Started', 'contact-form-7' ) ); ?></h3>
28
+ <ul>
29
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/getting-started-with-contact-form-7/', 'contact-form-7' ), __( 'Getting Started with Contact Form 7', 'contact-form-7' ) ); ?></li>
30
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/admin-screen/', 'contact-form-7' ), __( 'Admin Screen', 'contact-form-7' ) ); ?></li>
31
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/tag-syntax/', 'contact-form-7' ), __( 'How Tags Work', 'contact-form-7' ) ); ?></li>
32
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/setting-up-mail/', 'contact-form-7' ), __( 'Setting Up Mail', 'contact-form-7' ) ); ?></li>
33
+ </ul>
34
+ </div>
35
+
36
+ <div class="welcome-panel-column">
37
+ <h3><?php echo esc_html( __( 'Did You Know?', 'contact-form-7' ) ); ?></h3>
38
+ <ul>
39
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), __( 'Spam Filtering with Akismet', 'contact-form-7' ) ); ?></li>
40
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ), __( 'Save Messages with Flamingo', 'contact-form-7' ) ); ?></li>
41
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/selectable-recipient-with-pipes/', 'contact-form-7' ), __( 'Selectable Recipient with Pipes', 'contact-form-7' ) ); ?></li>
42
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/tracking-form-submissions-with-google-analytics/', 'contact-form-7' ), __( 'Tracking with Google Analytics', 'contact-form-7' ) ); ?></li>
43
+ </ul>
44
+ </div>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ <?php
49
+ }
50
+
51
+ add_action( 'wp_ajax_wpcf7-update-welcome-panel', 'wpcf7_admin_ajax_welcome_panel' );
52
+
53
+ function wpcf7_admin_ajax_welcome_panel() {
54
+ check_ajax_referer( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce' );
55
+
56
+ $vers = get_user_meta( get_current_user_id(),
57
+ 'wpcf7_hide_welcome_panel_on', true );
58
+
59
+ if ( empty( $vers ) || ! is_array( $vers ) ) {
60
+ $vers = array();
61
+ }
62
+
63
+ if ( empty( $_POST['visible'] ) ) {
64
+ $vers[] = WPCF7_VERSION;
65
+ }
66
+
67
+ $vers = array_unique( $vers );
68
+
69
+ update_user_meta( get_current_user_id(), 'wpcf7_hide_welcome_panel_on', $vers );
70
+
71
+ wp_die( 1 );
72
+ }
admin/js/scripts.js CHANGED
@@ -1,5 +1,7 @@
1
(function($) {
2
3
if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
4
_wpcf7 = {};
5
}
@@ -53,6 +55,34 @@
53
window.getSelection().addRange(range);
54
});
55
56
$(window).on('beforeunload', function(event) {
57
var changed = false;
58
@@ -61,6 +91,12 @@
61
if (this.defaultChecked != $(this).is(':checked')) {
62
changed = true;
63
}
64
} else {
65
if (this.defaultValue != $(this).val()) {
66
changed = true;
1
(function($) {
2
3
+ 'use strict';
4
+
5
if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
6
_wpcf7 = {};
7
}
55
window.getSelection().addRange(range);
56
});
57
58
+ $('[data-config-field]').each(function() {
59
+ var section = $(this).attr('data-config-field');
60
+
61
+ if (_wpcf7.configErrors[section]) {
62
+ var $list = $('<ul></ul>').attr({
63
+ 'role': 'alert',
64
+ 'class': 'config-error'
65
+ });
66
+
67
+ $.each(_wpcf7.configErrors[section], function(i, val) {
68
+ var $li = $('<li></li>').text(val.message);
69
+
70
+ if (val.link) {
71
+ var $link = $('<a></a>').attr({
72
+ 'href': val.link,
73
+ 'class': 'external'
74
+ }).text(_wpcf7.howToCorrectLink);
75
+
76
+ $li = $li.append(' ').append($link);
77
+ }
78
+
79
+ $li.appendTo($list);
80
+ });
81
+
82
+ $(this).after($list).attr({'aria-invalid': 'true'});
83
+ }
84
+ });
85
+
86
$(window).on('beforeunload', function(event) {
87
var changed = false;
88
91
if (this.defaultChecked != $(this).is(':checked')) {
92
changed = true;
93
}
94
+ } else if ($(this).is('select')) {
95
+ $(this).find('option').each(function() {
96
+ if (this.defaultSelected != $(this).is(':selected')) {
97
+ changed = true;
98
+ }
99
+ });
100
} else {
101
if (this.defaultValue != $(this).val()) {
102
changed = true;
admin/js/tag-generator.js CHANGED
@@ -1,5 +1,7 @@
1
(function($) {
2
3
if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
4
_wpcf7 = {};
5
}
@@ -59,7 +61,7 @@
59
tag_type += '*';
60
}
61
62
- components = _wpcf7.taggen.compose(tag_type, $form);
63
$(this).val(components);
64
});
65
1
(function($) {
2
3
+ 'use strict';
4
+
5
if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
6
_wpcf7 = {};
7
}
61
tag_type += '*';
62
}
63
64
+ var components = _wpcf7.taggen.compose(tag_type, $form);
65
$(this).val(components);
66
});
67
includes/config-validator.php CHANGED
@@ -2,40 +2,111 @@
2
3
class WPCF7_ConfigValidator {
4
5
const error_maybe_empty = 101;
6
const error_invalid_syntax = 102;
7
const error_email_not_in_site_domain = 103;
8
const error_html_in_message = 104;
9
10
private $contact_form;
11
private $errors = array();
12
13
public function __construct( WPCF7_ContactForm $contact_form ) {
14
$this->contact_form = $contact_form;
15
- $this->errors = (array) get_post_meta(
16
- $this->contact_form->id(), '_config_errors', true );
17
- $this->errors = array_filter( $this->errors );
18
}
19
20
public function is_valid() {
21
- return ! $this->errors;
22
}
23
24
- public function get_errors() {
25
- return $this->errors;
26
}
27
28
- public function get_error( $section ) {
29
- if ( isset( $this->errors[$section] ) ) {
30
- return $this->errors[$section];
31
}
32
33
- return null;
34
}
35
36
- public function get_error_message( $section ) {
37
- $code = $this->get_error( $section );
38
39
switch ( $code ) {
40
case self::error_maybe_empty:
41
return __( "This field can be empty depending on user input.", 'contact-form-7' );
@@ -45,31 +116,93 @@ class WPCF7_ConfigValidator {
45
return __( "This email address does not belong to the same domain as the site.", 'contact-form-7' );
46
case self::error_html_in_message:
47
return __( "HTML tags are not allowed in a message.", 'contact-form-7' );
48
default:
49
return '';
50
}
51
}
52
53
- private function add_error( $section, $error ) {
54
- $this->errors[$section] = $error;
55
}
56
57
public function validate() {
58
$this->errors = array();
59
60
$this->validate_mail( 'mail' );
61
$this->validate_mail( 'mail_2' );
62
$this->validate_messages();
63
64
delete_post_meta( $this->contact_form->id(), '_config_errors' );
65
66
if ( $this->errors ) {
67
update_post_meta( $this->contact_form->id(), '_config_errors',
68
$this->errors );
69
- return false;
70
}
71
72
- return true;
73
}
74
75
public function validate_mail( $template = 'mail' ) {
@@ -100,7 +233,8 @@ class WPCF7_ConfigValidator {
100
101
if ( '' === $subject ) {
102
$this->add_error( sprintf( '%s.subject', $template ),
103
- self::error_maybe_empty );
104
}
105
106
$sender = $components['sender'];
@@ -111,10 +245,12 @@ class WPCF7_ConfigValidator {
111
112
if ( ! wpcf7_is_mailbox_list( $sender ) ) {
113
$this->add_error( sprintf( '%s.sender', $template ),
114
- self::error_invalid_syntax );
115
} elseif ( ! wpcf7_is_email_in_site_domain( $sender ) ) {
116
$this->add_error( sprintf( '%s.sender', $template ),
117
- self::error_email_not_in_site_domain );
118
}
119
120
$recipient = $components['recipient'];
@@ -125,34 +261,18 @@ class WPCF7_ConfigValidator {
125
126
if ( ! wpcf7_is_mailbox_list( $recipient ) ) {
127
$this->add_error( sprintf( '%s.recipient', $template ),
128
- self::error_invalid_syntax );
129
}
130
131
$additional_headers = $components['additional_headers'];
132
$additional_headers = new WPCF7_MailTaggedText( $additional_headers,
133
array( 'callback' => $callback ) );
134
$additional_headers = $additional_headers->replace_tags();
135
136
- if ( ! $this->test_additional_headers_syntax( $additional_headers ) ) {
137
- $this->add_error( sprintf( '%s.additional_headers', $template ),
138
- self::error_invalid_syntax );
139
- }
140
-
141
- $body = $components['body'];
142
- $body = new WPCF7_MailTaggedText( $body,
143
- array( 'callback' => $callback ) );
144
- $body = $body->replace_tags();
145
-
146
- if ( '' === $body ) {
147
- $this->add_error( sprintf( '%s.body', $template ),
148
- self::error_maybe_empty );
149
- }
150
- }
151
-
152
- public function test_additional_headers_syntax( $content ) {
153
- $headers = explode( "\n", $content );
154
-
155
- foreach ( $headers as $header ) {
156
$header = trim( $header );
157
158
if ( '' === $header ) {
@@ -160,19 +280,30 @@ class WPCF7_ConfigValidator {
160
}
161
162
if ( ! preg_match( '/^([0-9A-Za-z-]+):(.+)#x2F;', $header, $matches ) ) {
163
- return false;
164
- }
165
-
166
- $is_mailbox_list_field = in_array( strtolower( $matches[1] ),
167
- array( 'reply-to', 'cc', 'bcc' ) );
168
-
169
- if ( $is_mailbox_list_field
170
&& ! wpcf7_is_mailbox_list( $matches[2] ) ) {
171
- return false;
172
}
173
}
174
175
- return true;
176
}
177
178
public function validate_messages() {
@@ -192,7 +323,8 @@ class WPCF7_ConfigValidator {
192
193
if ( $stripped != $message ) {
194
$this->add_error( sprintf( 'messages.%s', $key ),
195
- self::error_html_in_message );
196
}
197
}
198
}
2
3
class WPCF7_ConfigValidator {
4
5
+ const error = 100;
6
const error_maybe_empty = 101;
7
const error_invalid_syntax = 102;
8
const error_email_not_in_site_domain = 103;
9
const error_html_in_message = 104;
10
+ const error_multiple_controls_in_label = 105;
11
12
private $contact_form;
13
private $errors = array();
14
15
public function __construct( WPCF7_ContactForm $contact_form ) {
16
$this->contact_form = $contact_form;
17
+
18
+ $config_errors = get_post_meta( $contact_form->id(),
19
+ '_config_errors', true );
20
+
21
+ foreach ( (array) $config_errors as $section => $errors ) {
22
+ if ( empty( $errors ) ) {
23
+ continue;
24
+ }
25
+
26
+ if ( ! is_array( $errors ) ) { // for back-compat
27
+ $code = $errors;
28
+ $this->add_error( $section, $code );
29
+ } else {
30
+ foreach ( (array) $errors as $error ) {
31
+ if ( ! empty( $error['code'] ) ) {
32
+ $code = $error['code'];
33
+ $args = isset( $error['args'] ) ? $error['args'] : '';
34
+ $this->add_error( $section, $code, $args );
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ public function contact_form() {
42
+ return $this->contact_form;
43
}
44
45
public function is_valid() {
46
+ return ! $this->count_errors();
47
}
48
49
+ public function count_errors() {
50
+ $count = 0;
51
+
52
+ foreach( $this->errors as $errors ) {
53
+ $count += count( array_filter( $errors ) );
54
+ }
55
+
56
+ return $count;
57
}
58
59
+ public function collect_error_messages() {
60
+ $error_messages = array();
61
+
62
+ foreach ( $this->errors as $section => $errors ) {
63
+ $error_messages[$section] = array();
64
+
65
+ foreach ( $errors as $error ) {
66
+ if ( empty( $error['args']['message'] ) ) {
67
+ $message = $this->get_default_message( $error['code'] );
68
+ } elseif ( empty( $error['args']['params'] ) ) {
69
+ $message = $error['args']['message'];
70
+ } else {
71
+ $message = $this->build_message(
72
+ $error['args']['message'],
73
+ $error['args']['params'] );
74
+ }
75
+
76
+ $link = '';
77
+
78
+ if ( ! empty( $error['args']['link'] ) ) {
79
+ $link = $error['args']['link'];
80
+ }
81
+
82
+ $error_messages[$section][] = array(
83
+ 'message' => $message,
84
+ 'link' => $link );
85
+ }
86
}
87
88
+ return $error_messages;
89
}
90
91
+ public function build_message( $message, $params = '' ) {
92
+ $params = wp_parse_args( $params, array() );
93
+
94
+ foreach ( $params as $key => $val ) {
95
+ if ( ! preg_match( '/^[0-9A-Za-z_]+#x2F;', $key ) ) { // invalid key
96
+ continue;
97
+ }
98
+
99
+ $placeholder = '%' . $key . '%';
100
+
101
+ if ( false !== stripos( $message, $placeholder ) ) {
102
+ $message = str_ireplace( $placeholder, $val, $message );
103
+ }
104
+ }
105
+
106
+ return $message;
107
+ }
108
109
+ public function get_default_message( $code ) {
110
switch ( $code ) {
111
case self::error_maybe_empty:
112
return __( "This field can be empty depending on user input.", 'contact-form-7' );
116
return __( "This email address does not belong to the same domain as the site.", 'contact-form-7' );
117
case self::error_html_in_message:
118
return __( "HTML tags are not allowed in a message.", 'contact-form-7' );
119
+ case self::error_multiple_controls_in_label:
120
+ return __( "Multiple form controls are placed inside a single label element.", 'contact-form-7' );
121
default:
122
return '';
123
}
124
}
125
126
+ public function add_error( $section, $code, $args = '' ) {
127
+ $args = wp_parse_args( $args, array(
128
+ 'message' => '',
129
+ 'params' => array() ) );
130
+
131
+ if ( ! isset( $this->errors[$section] ) ) {
132
+ $this->errors[$section] = array();
133
+ }
134
+
135
+ $this->errors[$section][] = array( 'code' => $code, 'args' => $args );
136
+ }
137
+
138
+ public function remove_error( $section, $code ) {
139
+ if ( empty( $this->errors[$section] ) ) {
140
+ return;
141
+ }
142
+
143
+ foreach ( (array) $this->errors[$section] as $key => $error ) {
144
+ if ( isset( $error['code'] ) && $error['code'] == $code ) {
145
+ unset( $this->errors[$section][$key] );
146
+ }
147
+ }
148
}
149
150
public function validate() {
151
$this->errors = array();
152
153
+ $this->validate_form();
154
$this->validate_mail( 'mail' );
155
$this->validate_mail( 'mail_2' );
156
$this->validate_messages();
157
158
+ do_action( 'wpcf7_config_validator_validate', $this );
159
+
160
+ $this->save();
161
+ return $this->is_valid();
162
+ }
163
+
164
+ public function save() {
165
delete_post_meta( $this->contact_form->id(), '_config_errors' );
166
167
if ( $this->errors ) {
168
update_post_meta( $this->contact_form->id(), '_config_errors',
169
$this->errors );
170
}
171
+ }
172
+
173
+ public function validate_form() {
174
+ $body = $this->contact_form->prop( 'form' );
175
+ $pattern = '%<label(?:[ \t\n]+.*?)?>(.+?)</label>%s';
176
+
177
+ if ( preg_match_all( $pattern, $body, $matches ) ) {
178
+ $manager = WPCF7_ShortcodeManager::get_instance();
179
+
180
+ foreach ( $matches[1] as $insidelabel ) {
181
+ $tags = $manager->scan_shortcode( $insidelabel );
182
+ $fields_count = 0;
183
+
184
+ foreach ( $tags as $tag ) {
185
+ $tag = new WPCF7_Shortcode( $tag );
186
+
187
+ if ( in_array( $tag->basetype, array( 'checkbox', 'radio' ) ) ) {
188
+ $fields_count += count( $tag->values );
189
190
+ if ( $tag->has_option( 'free_text' ) ) {
191
+ $fields_count += 1;
192
+ }
193
+ } elseif ( ! empty( $tag->name ) ) {
194
+ $fields_count += 1;
195
+ }
196
+
197
+ if ( 1 < $fields_count ) {
198
+ $this->add_error( 'form.body',
199
+ self::error_multiple_controls_in_label,
200
+ array( 'link' => __( 'http://contactform7.com/configuration-errors/#form.body:error_multiple_controls_in_label', 'contact-form-7' ) ) );
201
+ return;
202
+ }
203
+ }
204
+ }
205
+ }
206
}
207
208
public function validate_mail( $template = 'mail' ) {
233
234
if ( '' === $subject ) {
235
$this->add_error( sprintf( '%s.subject', $template ),
236
+ self::error_maybe_empty,
237
+ array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.subject:error_maybe_empty', 'contact-form-7' ) ) );
238
}
239
240
$sender = $components['sender'];
245
246
if ( ! wpcf7_is_mailbox_list( $sender ) ) {
247
$this->add_error( sprintf( '%s.sender', $template ),
248
+ self::error_invalid_syntax,
249
+ array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.sender:error_invalid_syntax', 'contact-form-7' ) ) );
250
} elseif ( ! wpcf7_is_email_in_site_domain( $sender ) ) {
251
$this->add_error( sprintf( '%s.sender', $template ),
252
+ self::error_email_not_in_site_domain,
253
+ array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.sender:error_email_not_in_site_domain', 'contact-form-7' ) ) );
254
}
255
256
$recipient = $components['recipient'];
261
262
if ( ! wpcf7_is_mailbox_list( $recipient ) ) {
263
$this->add_error( sprintf( '%s.recipient', $template ),
264
+ self::error_invalid_syntax,
265
+ array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.recipient:error_invalid_syntax', 'contact-form-7' ) ) );
266
}
267
268
$additional_headers = $components['additional_headers'];
269
$additional_headers = new WPCF7_MailTaggedText( $additional_headers,
270
array( 'callback' => $callback ) );
271
$additional_headers = $additional_headers->replace_tags();
272
+ $additional_headers = explode( "\n", $additional_headers );
273
+ $mailbox_header_types = array( 'reply-to', 'cc', 'bcc' );
274
275
+ foreach ( $additional_headers as $header ) {
276
$header = trim( $header );
277
278
if ( '' === $header ) {
280
}
281
282
if ( ! preg_match( '/^([0-9A-Za-z-]+):(.+)#x2F;', $header, $matches ) ) {
283
+ $this->add_error( sprintf( '%s.additional_headers', $template ),
284
+ self::error_invalid_syntax,
285
+ array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.additional_headers:error_invalid_syntax', 'contact-form-7' ) ) );
286
+ } elseif ( in_array( strtolower( $matches[1] ), $mailbox_header_types )
287
&& ! wpcf7_is_mailbox_list( $matches[2] ) ) {
288
+ $this->add_error( sprintf( '%s.additional_headers', $template ),
289
+ self::error_invalid_syntax, array(
290
+ 'message' =>
291
+ __( "The %name% field value is invalid.", 'contact-form-7' ),
292
+ 'params' => array( 'name' => $matches[1] ),
293
+ 'link' => __( 'http://contactform7.com/configuration-errors/#mail.additional_headers:error_invalid_syntax', 'contact-form-7' ) ) );
294
}
295
}
296
297
+ $body = $components['body'];
298
+ $body = new WPCF7_MailTaggedText( $body,
299
+ array( 'callback' => $callback ) );
300
+ $body = $body->replace_tags();
301
+
302
+ if ( '' === $body ) {
303
+ $this->add_error( sprintf( '%s.body', $template ),
304
+ self::error_maybe_empty,
305
+ array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.body:error_maybe_empty', 'contact-form-7' ) ) );
306
+ }
307
}
308
309
public function validate_messages() {
323
324
if ( $stripped != $message ) {
325
$this->add_error( sprintf( 'messages.%s', $key ),
326
+ self::error_html_in_message,
327
+ array( 'link' => __( 'http://contactform7.com/configuration-errors/#messages:error_html_in_message', 'contact-form-7' ) ) );
328
}
329
}
330
}
includes/contact-form-template.php CHANGED
@@ -19,20 +19,29 @@ class WPCF7_ContactFormTemplate {
19
}
20
21
public static function form() {
22
- $template =
23
- '<p>' . __( 'Your Name', 'contact-form-7' )
24
- . ' ' . __( '(required)', 'contact-form-7' ) . '<br />' . "\n"
25
- . ' [text* your-name] </p>' . "\n\n"
26
- . '<p>' . __( 'Your Email', 'contact-form-7' )
27
- . ' ' . __( '(required)', 'contact-form-7' ) . '<br />' . "\n"
28
- . ' [email* your-email] </p>' . "\n\n"
29
- . '<p>' . __( 'Subject', 'contact-form-7' ) . '<br />' . "\n"
30
- . ' [text your-subject] </p>' . "\n\n"
31
- . '<p>' . __( 'Your Message', 'contact-form-7' ) . '<br />' . "\n"
32
- . ' [textarea your-message] </p>' . "\n\n"
33
- . '<p>[submit "' . __( 'Send', 'contact-form-7' ) . '"]</p>';
34
35
- return $template;
36
}
37
38
public static function mail() {
19
}
20
21
public static function form() {
22
+ $template = sprintf(
23
+ '
24
+ <label> %2$s %1$s
25
+ [text* your-name] </label>
26
27
+ <label> %3$s %1$s
28
+ [email* your-email] </label>
29
+
30
+ <label> %4$s
31
+ [text your-subject] </label>
32
+
33
+ <label> %5$s
34
+ [textarea your-message] </label>
35
+
36
+ [submit "%6$s"]',
37
+ __( '(required)', 'contact-form-7' ),
38
+ __( 'Your Name', 'contact-form-7' ),
39
+ __( 'Your Email', 'contact-form-7' ),
40
+ __( 'Subject', 'contact-form-7' ),
41
+ __( 'Your Message', 'contact-form-7' ),
42
+ __( 'Send', 'contact-form-7' ) );
43
+
44
+ return trim( $template );
45
}
46
47
public static function mail() {
includes/contact-form.php CHANGED
@@ -14,7 +14,6 @@ class WPCF7_ContactForm {
14
private $unit_tag;
15
private $responses_count = 0;
16
private $scanned_form_tags;
17
- private $config_validator;
18
19
public static function count() {
20
return self::$found_items;
@@ -317,14 +316,17 @@ class WPCF7_ContactForm {
317
$class = apply_filters( 'wpcf7_form_class_attr', $class );
318
319
$enctype = apply_filters( 'wpcf7_form_enctype', '' );
320
321
- $novalidate = apply_filters( 'wpcf7_form_novalidate', wpcf7_support_html5() );
322
323
$atts = array(
324
'action' => esc_url( $url ),
325
'method' => 'post',
326
'class' => $class,
327
'enctype' => wpcf7_enctype_value( $enctype ),
328
'novalidate' => $novalidate ? 'novalidate' : '' );
329
330
if ( '' !== $id_attr ) {
@@ -811,41 +813,6 @@ class WPCF7_ContactForm {
811
812
return apply_filters( 'wpcf7_contact_form_shortcode', $shortcode, $args, $this );
813
}
814
-
815
- public function validate_configuration() {
816
- if ( ! $this->initial() ) {
817
- if ( ! $this->config_validator ) {
818
- $this->config_validator = new WPCF7_ConfigValidator( $this );
819
- }
820
-
821
- $this->config_validator->validate();
822
- }
823
- }
824
-
825
- public function get_config_errors() {
826
- if ( ! $this->initial() ) {
827
- if ( ! $this->config_validator ) {
828
- $this->config_validator = new WPCF7_ConfigValidator( $this );
829
- }
830
-
831
- return $this->config_validator->get_errors();
832
- }
833
-
834
- return array();
835
- }
836
-
837
- public function config_error( $section ) {
838
- if ( ! $this->initial() ) {
839
- if ( ! $this->config_validator ) {
840
- $this->config_validator = new WPCF7_ConfigValidator( $this );
841
- }
842
-
843
- return $this->config_validator->get_error_message( $section );
844
- }
845
-
846
- return '';
847
- }
848
-
849
}
850
851
function wpcf7_contact_form( $id ) {
14
private $unit_tag;
15
private $responses_count = 0;
16
private $scanned_form_tags;
17
18
public static function count() {
19
return self::$found_items;
316
$class = apply_filters( 'wpcf7_form_class_attr', $class );
317
318
$enctype = apply_filters( 'wpcf7_form_enctype', '' );
319
+ $autocomplete = apply_filters( 'wpcf7_form_autocomplete', '' );
320
321
+ $novalidate = apply_filters( 'wpcf7_form_novalidate',
322
+ wpcf7_support_html5() );
323
324
$atts = array(
325
'action' => esc_url( $url ),
326
'method' => 'post',
327
'class' => $class,
328
'enctype' => wpcf7_enctype_value( $enctype ),
329
+ 'autocomplete' => $autocomplete,
330
'novalidate' => $novalidate ? 'novalidate' : '' );
331
332
if ( '' !== $id_attr ) {
813
814
return apply_filters( 'wpcf7_contact_form_shortcode', $shortcode, $args, $this );
815
}
816
}
817
818
function wpcf7_contact_form( $id ) {
includes/controller.php CHANGED
@@ -166,8 +166,10 @@ function wpcf7_enqueue_scripts() {
166
167
$_wpcf7 = array(
168
'loaderUrl' => wpcf7_ajax_loader(),
169
- 'recaptchaEmpty' =>
170
- __( 'Please verify that you are not a robot.', 'contact-form-7' ),
171
'sending' => __( 'Sending ...', 'contact-form-7' ) );
172
173
if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
166
167
$_wpcf7 = array(
168
'loaderUrl' => wpcf7_ajax_loader(),
169
+ 'recaptcha' => array(
170
+ 'messages' => array(
171
+ 'empty' => __( 'Please verify that you are not a robot.',
172
+ 'contact-form-7' ) ) ),
173
'sending' => __( 'Sending ...', 'contact-form-7' ) );
174
175
if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
includes/css/styles.css CHANGED
@@ -76,3 +76,7 @@ div.wpcf7 div.ajax-error {
76
div.wpcf7 .placeheld {
77
color: #888;
78
}
76
div.wpcf7 .placeheld {
77
color: #888;
78
}
79
+
80
+ .wpcf7-recaptcha iframe {
81
+ margin-bottom: 0;
82
+ }
includes/formatting.php CHANGED
@@ -177,7 +177,7 @@ function wpcf7_is_url( $url ) {
177
}
178
179
function wpcf7_is_tel( $tel ) {
180
- $result = preg_match( '/^[+]?[0-9() -]*#x2F;', $tel );
181
return apply_filters( 'wpcf7_is_tel', $result, $tel );
182
}
183
177
}
178
179
function wpcf7_is_tel( $tel ) {
180
+ $result = preg_match( '%^[+]?[0-9()/ -]*$%', $tel );
181
return apply_filters( 'wpcf7_is_tel', $result, $tel );
182
}
183
includes/functions.php CHANGED
@@ -250,8 +250,17 @@ function wpcf7_enctype_value( $enctype ) {
250
251
function wpcf7_rmdir_p( $dir ) {
252
if ( is_file( $dir ) ) {
253
- @unlink( $dir );
254
- return true;
255
}
256
257
if ( ! is_dir( $dir ) ) {
250
251
function wpcf7_rmdir_p( $dir ) {
252
if ( is_file( $dir ) ) {
253
+ if ( ! $result = @unlink( $dir ) ) {
254
+ $stat = @stat( $dir );
255
+ $perms = $stat['mode'];
256
+ @chmod( $dir, $perms | 0200 ); // add write for owner
257
+
258
+ if ( ! $result = @unlink( $dir ) ) {
259
+ @chmod( $dir, $perms );
260
+ }
261
+ }
262
+
263
+ return $result;
264
}
265
266
if ( ! is_dir( $dir ) ) {
includes/js/scripts.js CHANGED
@@ -1,5 +1,7 @@
1
(function($) {
2
3
if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
4
_wpcf7 = {};
5
}
@@ -74,6 +76,8 @@
74
this.find('.wpcf7-validates-as-url').change(function() {
75
$(this).wpcf7NormalizeUrl();
76
});
77
};
78
79
$.wpcf7AjaxSuccess = function(data, status, xhr, $form) {
@@ -113,7 +117,7 @@
113
$form.find('[name="g-recaptcha-response"]').each(function() {
114
if ('' == $(this).val()) {
115
var $recaptcha = $(this).closest('.wpcf7-form-control-wrap');
116
- $recaptcha.wpcf7NotValidTip(_wpcf7.recaptchaEmpty);
117
}
118
});
119
@@ -394,6 +398,19 @@
394
});
395
};
396
397
$.wpcf7UpdateScreenReaderResponse = function($form, data) {
398
$('.wpcf7 .screen-reader-response').html('').attr('role', '');
399
1
(function($) {
2
3
+ 'use strict';
4
+
5
if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
6
_wpcf7 = {};
7
}
76
this.find('.wpcf7-validates-as-url').change(function() {
77
$(this).wpcf7NormalizeUrl();
78
});
79
+
80
+ this.find('.wpcf7-recaptcha').wpcf7Recaptcha();
81
};
82
83
$.wpcf7AjaxSuccess = function(data, status, xhr, $form) {
117
$form.find('[name="g-recaptcha-response"]').each(function() {
118
if ('' == $(this).val()) {
119
var $recaptcha = $(this).closest('.wpcf7-form-control-wrap');
120
+ $recaptcha.wpcf7NotValidTip(_wpcf7.recaptcha.messages.empty);
121
}
122
});
123
398
});
399
};
400
401
+ $.fn.wpcf7Recaptcha = function() {
402
+ return this.each(function() {
403
+ var events = 'wpcf7:spam wpcf7:mailsent wpcf7:mailfailed';
404
+ $(this).closest('div.wpcf7').on(events, function(e) {
405
+ if (recaptchaWidgets && grecaptcha) {
406
+ $.each(recaptchaWidgets, function(index, value) {
407
+ grecaptcha.reset(value);
408
+ });
409
+ }
410
+ });
411
+ });
412
+ };
413
+
414
$.wpcf7UpdateScreenReaderResponse = function($form, data) {
415
$('.wpcf7 .screen-reader-response').html('').attr('role', '');
416
includes/submission.php CHANGED
@@ -284,7 +284,7 @@ class WPCF7_Submission {
284
285
public function remove_uploaded_files() {
286
foreach ( (array) $this->uploaded_files as $name => $path ) {
287
- @unlink( $path );
288
@rmdir( dirname( $path ) ); // remove parent dir if it's removable (empty).
289
}
290
}
284
285
public function remove_uploaded_files() {
286
foreach ( (array) $this->uploaded_files as $name => $path ) {
287
+ wpcf7_rmdir_p( $path );
288
@rmdir( dirname( $path ) ); // remove parent dir if it's removable (empty).
289
}
290
}
languages/contact-form-7-cs_CZ.mo DELETED
Binary file
languages/contact-form-7-da_DK.mo DELETED
Binary file
languages/contact-form-7-pl_PL.mo DELETED
Binary file
languages/readme.txt CHANGED
@@ -1,10 +1,9 @@
1
== For Translators ==
2
3
- We are migrating translations to translate.wordpress.org; the language files in this directory will be removed as soon as the languages are fully translated and available from translate.wordpress.org.
4
5
- For details, see
6
http://contactform7.com/2016/01/08/translations-migrate-to-translate-wordpress-org/
7
8
- We welcome your contribution to the collaborative translation project.
9
10
- Thank you.
1
== For Translators ==
2
3
+ We are in the process of migrating translations to translate.wordpress.org.
4
5
http://contactform7.com/2016/01/08/translations-migrate-to-translate-wordpress-org/
6
7
+ The language files in this directory will no longer be updated and will be removed at some point in the future.
8
9
+ Thank you for your past contribution, and see you at translate.wordpress.org :)
modules/count.php CHANGED
@@ -18,19 +18,24 @@ function wpcf7_count_shortcode_handler( $tag ) {
18
return '';
19
}
20
21
- $target = wpcf7_scan_shortcode( array( 'name' => $tag->name ) );
22
$maxlength = $minlength = null;
23
24
- if ( $target ) {
25
- $target = new WPCF7_Shortcode( $target[0] );
26
- $maxlength = $target->get_maxlength_option();
27
- $minlength = $target->get_minlength_option();
28
29
- if ( $maxlength && $minlength && $maxlength < $minlength ) {
30
- $maxlength = $minlength = null;
31
}
32
}
33
34
if ( $tag->has_option( 'down' ) ) {
35
$value = (int) $maxlength;
36
$class = 'wpcf7-character-count down';
@@ -53,5 +58,3 @@ function wpcf7_count_shortcode_handler( $tag ) {
53
54
return $html;
55
}
56
-
57
- ?>
18
return '';
19
}
20
21
+ $targets = wpcf7_scan_shortcode( array( 'name' => $tag->name ) );
22
$maxlength = $minlength = null;
23
24
+ while ( $targets ) {
25
+ $target = array_shift( $targets );
26
+ $target = new WPCF7_Shortcode( $target );
27
28
+ if ( 'count' != $target->type ) {
29
+ $maxlength = $target->get_maxlength_option();
30
+ $minlength = $target->get_minlength_option();
31
+ break;
32
}
33
}
34
35
+ if ( $maxlength && $minlength && $maxlength < $minlength ) {
36
+ $maxlength = $minlength = null;
37
+ }
38
+
39
if ( $tag->has_option( 'down' ) ) {
40
$value = (int) $maxlength;
41
$class = 'wpcf7-character-count down';
58
59
return $html;
60
}
modules/file.php CHANGED
@@ -296,7 +296,7 @@ function wpcf7_tag_generator_file( $contact_form, $args = '' ) {
296
297
/* Warning message */
298
299
- add_action( 'wpcf7_admin_notices', 'wpcf7_file_display_warning_message' );
300
301
function wpcf7_file_display_warning_message() {
302
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
@@ -316,7 +316,7 @@ function wpcf7_file_display_warning_message() {
316
if ( ! is_dir( $uploads_dir ) || ! wp_is_writable( $uploads_dir ) ) {
317
$message = sprintf( __( 'This contact form contains file uploading fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir );
318
319
- echo '<div class="notice notice-error is-dismissible"><p>' . esc_html( $message ) . '</p></div>';
320
}
321
}
322
@@ -362,7 +362,7 @@ function wpcf7_upload_tmp_dir() {
362
363
add_action( 'template_redirect', 'wpcf7_cleanup_upload_files', 20 );
364
365
- function wpcf7_cleanup_upload_files() {
366
if ( is_admin() || 'GET' != $_SERVER['REQUEST_METHOD']
367
|| is_robots() || is_feed() || is_trackback() ) {
368
return;
@@ -374,6 +374,10 @@ function wpcf7_cleanup_upload_files() {
374
return;
375
}
376
377
if ( $handle = @opendir( $dir ) ) {
378
while ( false !== ( $file = readdir( $handle ) ) ) {
379
if ( $file == "." || $file == ".." || $file == ".htaccess" ) {
@@ -382,11 +386,16 @@ function wpcf7_cleanup_upload_files() {
382
383
$mtime = @filemtime( $dir . $file );
384
385
- if ( $mtime && time() < $mtime + 60 ) { // less than 60 secs old
386
continue;
387
}
388
389
wpcf7_rmdir_p( path_join( $dir, $file ) );
390
}
391
392
closedir( $handle );
296
297
/* Warning message */
298
299
+ add_action( 'wpcf7_admin_warnings', 'wpcf7_file_display_warning_message' );
300
301
function wpcf7_file_display_warning_message() {
302
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
316
if ( ! is_dir( $uploads_dir ) || ! wp_is_writable( $uploads_dir ) ) {
317
$message = sprintf( __( 'This contact form contains file uploading fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir );
318
319
+ echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
320
}
321
}
322
362
363
add_action( 'template_redirect', 'wpcf7_cleanup_upload_files', 20 );
364
365
+ function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) {
366
if ( is_admin() || 'GET' != $_SERVER['REQUEST_METHOD']
367
|| is_robots() || is_feed() || is_trackback() ) {
368
return;
374
return;
375
}
376
377
+ $seconds = absint( $seconds );
378
+ $max = absint( $max );
379
+ $count = 0;
380
+
381
if ( $handle = @opendir( $dir ) ) {
382
while ( false !== ( $file = readdir( $handle ) ) ) {
383
if ( $file == "." || $file == ".." || $file == ".htaccess" ) {
386
387
$mtime = @filemtime( $dir . $file );
388
389
+ if ( $mtime && time() < $mtime + $seconds ) { // less than $seconds old
390
continue;
391
}
392
393
wpcf7_rmdir_p( path_join( $dir, $file ) );
394
+ $count += 1;
395
+
396
+ if ( $max <= $count ) {
397
+ break;
398
+ }
399
}
400
401
closedir( $handle );
modules/quiz.php CHANGED
@@ -14,15 +14,17 @@ function wpcf7_add_shortcode_quiz() {
14
function wpcf7_quiz_shortcode_handler( $tag ) {
15
$tag = new WPCF7_Shortcode( $tag );
16
17
- if ( empty( $tag->name ) )
18
return '';
19
20
$validation_error = wpcf7_get_validation_error( $tag->name );
21
22
$class = wpcf7_form_controls_class( $tag->type );
23
24
- if ( $validation_error )
25
$class .= ' wpcf7-not-valid';
26
27
$atts = array();
28
@@ -37,6 +39,7 @@ function wpcf7_quiz_shortcode_handler( $tag ) {
37
$atts['class'] = $tag->get_class_option( $class );
38
$atts['id'] = $tag->get_id_option();
39
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
40
$atts['aria-required'] = 'true';
41
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
42
14
function wpcf7_quiz_shortcode_handler( $tag ) {
15
$tag = new WPCF7_Shortcode( $tag );
16
17
+ if ( empty( $tag->name ) ) {
18
return '';
19
+ }
20
21
$validation_error = wpcf7_get_validation_error( $tag->name );
22
23
$class = wpcf7_form_controls_class( $tag->type );
24
25
+ if ( $validation_error ) {
26
$class .= ' wpcf7-not-valid';
27
+ }
28
29
$atts = array();
30
39
$atts['class'] = $tag->get_class_option( $class );
40
$atts['id'] = $tag->get_id_option();
41
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
42
+ $atts['autocomplete'] = 'off';
43
$atts['aria-required'] = 'true';
44
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
45
modules/really-simple-captcha.php CHANGED
@@ -15,11 +15,13 @@ function wpcf7_add_shortcode_captcha() {
15
function wpcf7_captcha_shortcode_handler( $tag ) {
16
$tag = new WPCF7_Shortcode( $tag );
17
18
- if ( 'captchac' == $tag->type && ! class_exists( 'ReallySimpleCaptcha' ) )
19
return '<em>' . __( 'To use CAPTCHA, you need <a href="http://wordpress.org/extend/plugins/really-simple-captcha/">Really Simple CAPTCHA</a> plugin installed.', 'contact-form-7' ) . '</em>';
20
21
- if ( empty( $tag->name ) )
22
return '';
23
24
$validation_error = wpcf7_get_validation_error( $tag->name );
25
@@ -41,15 +43,18 @@ function wpcf7_captcha_shortcode_handler( $tag ) {
41
42
$op = array_merge( $op, wpcf7_captchac_options( $tag->options ) );
43
44
- if ( ! $filename = wpcf7_generate_captcha( $op ) )
45
return '';
46
47
if ( ! empty( $op['img_size'] ) ) {
48
- if ( isset( $op['img_size'][0] ) )
49
$atts['width'] = $op['img_size'][0];
50
51
- if ( isset( $op['img_size'][1] ) )
52
$atts['height'] = $op['img_size'][1];
53
}
54
55
$atts['alt'] = 'captcha';
@@ -66,8 +71,9 @@ function wpcf7_captcha_shortcode_handler( $tag ) {
66
return $html;
67
68
} elseif ( 'captchar' == $tag->type ) { // CAPTCHA-Response (input)
69
- if ( $validation_error )
70
$class .= ' wpcf7-not-valid';
71
72
$atts = array();
73
@@ -83,15 +89,17 @@ function wpcf7_captcha_shortcode_handler( $tag ) {
83
$atts['class'] = $tag->get_class_option( $class );
84
$atts['id'] = $tag->get_id_option();
85
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
86
-
87
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
88
89
$value = (string) reset( $tag->values );
90
91
- if ( wpcf7_is_posted() )
92
$value = '';
93
94
- if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
95
$atts['placeholder'] = $value;
96
$value = '';
97
}
@@ -281,7 +289,7 @@ function wpcf7_tag_generator_captcha( $contact_form, $args = '' ) {
281
282
/* Warning message */
283
284
- add_action( 'wpcf7_admin_notices', 'wpcf7_captcha_display_warning_message' );
285
286
function wpcf7_captcha_display_warning_message() {
287
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
@@ -305,13 +313,13 @@ function wpcf7_captcha_display_warning_message() {
305
if ( ! is_dir( $uploads_dir ) || ! wp_is_writable( $uploads_dir ) ) {
306
$message = sprintf( __( 'This contact form contains CAPTCHA fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir );
307
308
- echo '<div class="notice notice-error is-dismissible"><p>' . esc_html( $message ) . '</p></div>';
309
}
310
311
if ( ! function_exists( 'imagecreatetruecolor' ) || ! function_exists( 'imagettftext' ) ) {
312
$message = __( 'This contact form contains CAPTCHA fields, but the necessary libraries (GD and FreeType) are not available on your server.', 'contact-form-7' );
313
314
- echo '<div class="notice notice-error is-dismissible"><p>' . esc_html( $message ) . '</p></div>';
315
}
316
}
317
15
function wpcf7_captcha_shortcode_handler( $tag ) {
16
$tag = new WPCF7_Shortcode( $tag );
17
18
+ if ( 'captchac' == $tag->type && ! class_exists( 'ReallySimpleCaptcha' ) ) {
19
return '<em>' . __( 'To use CAPTCHA, you need <a href="http://wordpress.org/extend/plugins/really-simple-captcha/">Really Simple CAPTCHA</a> plugin installed.', 'contact-form-7' ) . '</em>';
20
+ }
21
22
+ if ( empty( $tag->name ) ) {
23
return '';
24
+ }
25
26
$validation_error = wpcf7_get_validation_error( $tag->name );
27
43
44
$op = array_merge( $op, wpcf7_captchac_options( $tag->options ) );
45
46
+ if ( ! $filename = wpcf7_generate_captcha( $op ) ) {
47
return '';
48
+ }
49
50
if ( ! empty( $op['img_size'] ) ) {
51
+ if ( isset( $op['img_size'][0] ) ) {
52
$atts['width'] = $op['img_size'][0];
53
+ }
54
55
+ if ( isset( $op['img_size'][1] ) ) {
56
$atts['height'] = $op['img_size'][1];
57
+ }
58
}
59
60
$atts['alt'] = 'captcha';
71
return $html;
72
73
} elseif ( 'captchar' == $tag->type ) { // CAPTCHA-Response (input)
74
+ if ( $validation_error ) {
75
$class .= ' wpcf7-not-valid';
76
+ }
77
78
$atts = array();
79
89
$atts['class'] = $tag->get_class_option( $class );
90
$atts['id'] = $tag->get_id_option();
91
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
92
+ $atts['autocomplete'] = 'off';
93
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
94
95
$value = (string) reset( $tag->values );
96
97
+ if ( wpcf7_is_posted() ) {
98
$value = '';
99
+ }
100
101
+ if ( $tag->has_option( 'placeholder' )
102
+ || $tag->has_option( 'watermark' ) ) {
103
$atts['placeholder'] = $value;
104
$value = '';
105
}
289
290
/* Warning message */
291
292
+ add_action( 'wpcf7_admin_warnings', 'wpcf7_captcha_display_warning_message' );
293
294
function wpcf7_captcha_display_warning_message() {
295
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
313
if ( ! is_dir( $uploads_dir ) || ! wp_is_writable( $uploads_dir ) ) {
314
$message = sprintf( __( 'This contact form contains CAPTCHA fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir );
315
316
+ echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
317
}
318
319
if ( ! function_exists( 'imagecreatetruecolor' ) || ! function_exists( 'imagettftext' ) ) {
320
$message = __( 'This contact form contains CAPTCHA fields, but the necessary libraries (GD and FreeType) are not available on your server.', 'contact-form-7' );
321
322
+ echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
323
}
324
}
325
modules/recaptcha.php CHANGED
@@ -249,6 +249,7 @@ function wpcf7_recaptcha_callback_script() {
249
250
?>
251
<script type="text/javascript">
252
var recaptchaCallback = function() {
253
var forms = document.getElementsByTagName('form');
254
var pattern = /(^|\s)g-recaptcha(\s|$)/;
@@ -260,7 +261,7 @@ var recaptchaCallback = function() {
260
var sitekey = divs[j].getAttribute('data-sitekey');
261
262
if (divs[j].className && divs[j].className.match(pattern) && sitekey) {
263
- grecaptcha.render(divs[j], {
264
'sitekey': sitekey,
265
'theme': divs[j].getAttribute('data-theme'),
266
'type': divs[j].getAttribute('data-type'),
@@ -270,6 +271,7 @@ var recaptchaCallback = function() {
270
'expired-callback': divs[j].getAttribute('data-expired-callback')
271
});
272
273
break;
274
}
275
}
249
250
?>
251
<script type="text/javascript">
252
+ var recaptchaWidgets = [];
253
var recaptchaCallback = function() {
254
var forms = document.getElementsByTagName('form');
255
var pattern = /(^|\s)g-recaptcha(\s|$)/;
261
var sitekey = divs[j].getAttribute('data-sitekey');
262
263
if (divs[j].className && divs[j].className.match(pattern) && sitekey) {
264
+ var widget_id = grecaptcha.render(divs[j], {
265
'sitekey': sitekey,
266
'theme': divs[j].getAttribute('data-theme'),
267
'type': divs[j].getAttribute('data-type'),
271
'expired-callback': divs[j].getAttribute('data-expired-callback')
272
});
273
274
+ recaptchaWidgets.push(widget_id);
275
break;
276
}
277
}
modules/text.php CHANGED
@@ -20,18 +20,21 @@ function wpcf7_add_shortcode_text() {
20
function wpcf7_text_shortcode_handler( $tag ) {
21
$tag = new WPCF7_Shortcode( $tag );
22
23
- if ( empty( $tag->name ) )
24
return '';
25
26
$validation_error = wpcf7_get_validation_error( $tag->name );
27
28
$class = wpcf7_form_controls_class( $tag->type, 'wpcf7-text' );
29
30
- if ( in_array( $tag->basetype, array( 'email', 'url', 'tel' ) ) )
31
$class .= ' wpcf7-validates-as-' . $tag->basetype;
32
33
- if ( $validation_error )
34
$class .= ' wpcf7-not-valid';
35
36
$atts = array();
37
@@ -39,7 +42,8 @@ function wpcf7_text_shortcode_handler( $tag ) {
39
$atts['maxlength'] = $tag->get_maxlength_option();
40
$atts['minlength'] = $tag->get_minlength_option();
41
42
- if ( $atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength'] ) {
43
unset( $atts['maxlength'], $atts['minlength'] );
44
}
45
@@ -47,11 +51,16 @@ function wpcf7_text_shortcode_handler( $tag ) {
47
$atts['id'] = $tag->get_id_option();
48
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
49
50
- if ( $tag->has_option( 'readonly' ) )
51
$atts['readonly'] = 'readonly';
52
53
- if ( $tag->is_required() )
54
$atts['aria-required'] = 'true';
55
56
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
57
20
function wpcf7_text_shortcode_handler( $tag ) {
21
$tag = new WPCF7_Shortcode( $tag );
22
23
+ if ( empty( $tag->name ) ) {
24
return '';
25
+ }
26
27
$validation_error = wpcf7_get_validation_error( $tag->name );
28
29
$class = wpcf7_form_controls_class( $tag->type, 'wpcf7-text' );
30
31
+ if ( in_array( $tag->basetype, array( 'email', 'url', 'tel' ) ) ) {
32
$class .= ' wpcf7-validates-as-' . $tag->basetype;
33
+ }
34
35
+ if ( $validation_error ) {
36
$class .= ' wpcf7-not-valid';
37
+ }
38
39
$atts = array();
40
42
$atts['maxlength'] = $tag->get_maxlength_option();
43
$atts['minlength'] = $tag->get_minlength_option();
44
45
+ if ( $atts['maxlength'] && $atts['minlength']
46
+ && $atts['maxlength'] < $atts['minlength'] ) {
47
unset( $atts['maxlength'], $atts['minlength'] );
48
}
49
51
$atts['id'] = $tag->get_id_option();
52
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
53
54
+ $atts['autocomplete'] = $tag->get_option( 'autocomplete',
55
+ '[-0-9a-zA-Z]+', true );
56
+
57
+ if ( $tag->has_option( 'readonly' ) ) {
58
$atts['readonly'] = 'readonly';
59
+ }
60
61
+ if ( $tag->is_required() ) {
62
$atts['aria-required'] = 'true';
63
+ }
64
65
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
66
modules/textarea.php CHANGED
@@ -15,15 +15,17 @@ function wpcf7_add_shortcode_textarea() {
15
function wpcf7_textarea_shortcode_handler( $tag ) {
16
$tag = new WPCF7_Shortcode( $tag );
17
18
- if ( empty( $tag->name ) )
19
return '';
20
21
$validation_error = wpcf7_get_validation_error( $tag->name );
22
23
$class = wpcf7_form_controls_class( $tag->type );
24
25
- if ( $validation_error )
26
$class .= ' wpcf7-not-valid';
27
28
$atts = array();
29
@@ -40,6 +42,9 @@ function wpcf7_textarea_shortcode_handler( $tag ) {
40
$atts['id'] = $tag->get_id_option();
41
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
42
43
if ( $tag->has_option( 'readonly' ) ) {
44
$atts['readonly'] = 'readonly';
45
}
15
function wpcf7_textarea_shortcode_handler( $tag ) {
16
$tag = new WPCF7_Shortcode( $tag );
17
18
+ if ( empty( $tag->name ) ) {
19
return '';
20
+ }
21
22
$validation_error = wpcf7_get_validation_error( $tag->name );
23
24
$class = wpcf7_form_controls_class( $tag->type );
25
26
+ if ( $validation_error ) {
27
$class .= ' wpcf7-not-valid';
28
+ }
29
30
$atts = array();
31
42
$atts['id'] = $tag->get_id_option();
43
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
44
45
+ $atts['autocomplete'] = $tag->get_option( 'autocomplete',
46
+ '[-0-9a-zA-Z]+', true );
47
+
48
if ( $tag->has_option( 'readonly' ) ) {
49
$atts['readonly'] = 'readonly';
50
}
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
Contributors: takayukister
3
Donate link: http://contactform7.com/donate/
4
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
5
- Requires at least: 4.3
6
- Tested up to: 4.5.1
7
- Stable tag: 4.4.2
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -29,7 +29,6 @@ The following plugins are recommended for Contact Form 7 users:
29
* [Flamingo](https://wordpress.org/plugins/flamingo/) by Takayuki Miyoshi - With Flamingo, you can save submitted messages via contact forms in the database.
30
* [Postman](https://wordpress.org/plugins/postman-smtp/) by
31
Jason Hendriks - Postman is a next-generation SMTP Mailer, software that assists in the delivery of email generated by your WordPress site.
32
- * [Contact Form 7: Accessible Defaults](https://wordpress.org/plugins/contact-form-7-accessible-defaults/) by Joe Dolson - Replaces the default Contact Form 7 form with an accessible equivalent and provides a suite of selectable base forms.
33
* [Bogo](https://wordpress.org/plugins/bogo/) by Takayuki Miyoshi - Bogo is a straight-forward multilingual plugin that doesn't cause headaches.
34
35
= Translations =
@@ -63,6 +62,15 @@ Do you have questions or issues with Contact Form 7? Use these support channels
63
64
For more information, see [Releases](http://contactform7.com/category/releases/).
65
66
= 4.4.2 =
67
68
* Language Packs: Language files for French (fr_FR), Russian (ru_RU), Slovak (sk_SK), and Turkish (tr_TR) have been removed from the plugin package.
2
Contributors: takayukister
3
Donate link: http://contactform7.com/donate/
4
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
5
+ Requires at least: 4.4
6
+ Tested up to: 4.6
7
+ Stable tag: 4.5
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
29
* [Flamingo](https://wordpress.org/plugins/flamingo/) by Takayuki Miyoshi - With Flamingo, you can save submitted messages via contact forms in the database.
30
* [Postman](https://wordpress.org/plugins/postman-smtp/) by
31
Jason Hendriks - Postman is a next-generation SMTP Mailer, software that assists in the delivery of email generated by your WordPress site.
32
* [Bogo](https://wordpress.org/plugins/bogo/) by Takayuki Miyoshi - Bogo is a straight-forward multilingual plugin that doesn't cause headaches.
33
34
= Translations =
62
63
For more information, see [Releases](http://contactform7.com/category/releases/).
64
65
+ = 4.5 =
66
+
67
+ * The default contact form template is revised.
68
+ * reCAPTCHA: Run grecaptcha.reset() after a submission.
69
+ * The autocomplete option for form-tags and wpcf7_form_autocomplete filter hook are introduced to manage autocomplete attribute.
70
+ * The config validator is revised. The wpcf7_config_validator_validate action hook is introduced to allow 3rd-party to cut in.
71
+ * A bug in character count form-tag is fixed.
72
+ * Language Packs: Language files for Danish (da_DK), Polish (pl_PL), and Czech (cs_CZ) have been removed from the plugin package.
73
+
74
= 4.4.2 =
75
76
* Language Packs: Language files for French (fr_FR), Russian (ru_RU), Slovak (sk_SK), and Turkish (tr_TR) have been removed from the plugin package.
wp-contact-form-7.php CHANGED
@@ -7,12 +7,12 @@ Author: Takayuki Miyoshi
7
Author URI: http://ideasilo.wordpress.com/
8
Text Domain: contact-form-7
9
Domain Path: /languages/
10
- Version: 4.4.2
11
*/
12
13
- define( 'WPCF7_VERSION', '4.4.2' );
14
15
- define( 'WPCF7_REQUIRED_WP_VERSION', '4.3' );
16
17
define( 'WPCF7_PLUGIN', __FILE__ );
18
7
Author URI: http://ideasilo.wordpress.com/
8
Text Domain: contact-form-7
9
Domain Path: /languages/
10
+ Version: 4.5
11
*/
12
13
+ define( 'WPCF7_VERSION', '4.5' );
14
15
+ define( 'WPCF7_REQUIRED_WP_VERSION', '4.4' );
16
17
define( 'WPCF7_PLUGIN', __FILE__ );
18