Contact Form 7 - Version 5.0

Version Description

Download this release

Release Info

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

Code changes from version 4.9.2 to 5.0

admin/admin.php CHANGED
@@ -236,7 +236,8 @@ function wpcf7_load_contact_form_admin() {
236
WPCF7::update_option( 'bulk_validate', $result );
237
238
$query = array(
239
- 'message' => 'validated' );
240
241
$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
242
wp_safe_redirect( $redirect_to );
@@ -273,7 +274,8 @@ function wpcf7_load_contact_form_admin() {
273
274
add_screen_option( 'per_page', array(
275
'default' => 20,
276
- 'option' => 'cfseven_contact_forms_per_page' ) );
277
}
278
}
279
@@ -314,12 +316,14 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
314
? (int) $_GET['active-tab'] : 0,
315
'configValidator' => array(
316
'errors' => array(),
317
- 'howToCorrect' => __( "How to correct this?", 'contact-form-7' ),
318
'oneError' => __( '1 configuration error detected', 'contact-form-7' ),
319
'manyErrors' => __( '%d configuration errors detected', 'contact-form-7' ),
320
'oneErrorInTab' => __( '1 configuration error detected in this tab panel', 'contact-form-7' ),
321
'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', 'contact-form-7' ),
322
'docUrl' => WPCF7_ConfigValidator::get_doc_link(),
323
),
324
);
325
@@ -541,8 +545,13 @@ function wpcf7_plugin_action_links( $links, $file ) {
541
return $links;
542
}
543
544
- $settings_link = '<a href="' . menu_page_url( 'wpcf7', false ) . '">'
545
- . esc_html( __( 'Settings', 'contact-form-7' ) ) . '</a>';
546
547
array_unshift( $links, $settings_link );
548
236
WPCF7::update_option( 'bulk_validate', $result );
237
238
$query = array(
239
+ 'message' => 'validated',
240
+ );
241
242
$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
243
wp_safe_redirect( $redirect_to );
274
275
add_screen_option( 'per_page', array(
276
'default' => 20,
277
+ 'option' => 'cfseven_contact_forms_per_page',
278
+ ) );
279
}
280
}
281
316
? (int) $_GET['active-tab'] : 0,
317
'configValidator' => array(
318
'errors' => array(),
319
+ 'howToCorrect' => __( "How to resolve?", 'contact-form-7' ),
320
'oneError' => __( '1 configuration error detected', 'contact-form-7' ),
321
'manyErrors' => __( '%d configuration errors detected', 'contact-form-7' ),
322
'oneErrorInTab' => __( '1 configuration error detected in this tab panel', 'contact-form-7' ),
323
'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', 'contact-form-7' ),
324
'docUrl' => WPCF7_ConfigValidator::get_doc_link(),
325
+ /* translators: screen reader text */
326
+ 'iconAlt' => __( '(configuration error)', 'contact-form-7' ),
327
),
328
);
329
545
return $links;
546
}
547
548
+ if ( ! current_user_can( 'wpcf7_read_contact_forms' ) ) {
549
+ return $links;
550
+ }
551
+
552
+ $settings_link = sprintf( '<a href="%1$s">%2$s</a>',
553
+ menu_page_url( 'wpcf7', false ),
554
+ esc_html( __( 'Settings', 'contact-form-7' ) ) );
555
556
array_unshift( $links, $settings_link );
557
admin/css/styles.css CHANGED
@@ -62,25 +62,19 @@ div.config-error, span.config-error, ul.config-error {
62
font-size: 13px;
63
}
64
65
- div.config-error span.dashicons {
66
- color: #82878c;
67
- }
68
-
69
ul.config-error {
70
- margin: 0;
71
}
72
73
ul.config-error li {
74
- list-style: disc inside;
75
- padding: 0 4px;
76
margin: 0;
77
}
78
79
- ul.config-error li a.external {
80
- font-style: normal;
81
- font-weight: normal;
82
- font-size: 18px;
83
- vertical-align: middle;
84
}
85
86
[data-config-field][aria-invalid="true"] {
@@ -144,6 +138,15 @@ ul.config-error li a.external {
144
color: #82878c;
145
}
146
147
#contact-form-editor-tabs li.ui-tabs-active a span.dashicons {
148
display: none;
149
}
@@ -224,6 +227,10 @@ ul.config-error li a.external {
224
width: 200px;
225
}
226
227
.tag-generator-panel .control-box textarea.values {
228
width: 200px;
229
height: 6em;
@@ -320,8 +327,8 @@ ul.config-error li a.external {
320
width: 38%;
321
}
322
323
- .wp-list-table .config-error span.dashicons {
324
- color: #82878c;
325
}
326
327
/*
62
font-size: 13px;
63
}
64
65
ul.config-error {
66
+ margin: 2px 0;
67
}
68
69
ul.config-error li {
70
+ list-style: none;
71
+ padding: 2px 2px;
72
margin: 0;
73
}
74
75
+ div.config-error span.dashicons,
76
+ ul.config-error li span.dashicons {
77
+ color: #82878c;
78
}
79
80
[data-config-field][aria-invalid="true"] {
138
color: #82878c;
139
}
140
141
+ #contact-form-editor-tabs li a span.dashicons-warning,
142
+ #contact-form-editor .contact-form-editor-panel > div.config-error span.dashicons-warning {
143
+ color: #ca4a1f;
144
+ }
145
+
146
+ #contact-form-editor .contact-form-editor-panel > div.config-error {
147
+ margin-bottom: 1.4em;
148
+ }
149
+
150
#contact-form-editor-tabs li.ui-tabs-active a span.dashicons {
151
display: none;
152
}
227
width: 200px;
228
}
229
230
+ .tag-generator-panel .control-box input.large-text {
231
+ width: 400px;
232
+ }
233
+
234
.tag-generator-panel .control-box textarea.values {
235
width: 200px;
236
height: 6em;
327
width: 38%;
328
}
329
330
+ .wp-list-table .config-error span.dashicons-warning {
331
+ color: #ca4a1f;
332
}
333
334
/*
admin/edit-contact-form.php CHANGED
@@ -88,8 +88,9 @@ if ( $post ) :
88
'id' => 'title',
89
'spellcheck' => 'true',
90
'autocomplete' => 'off',
91
- 'disabled' => current_user_can( 'wpcf7_edit_contact_form', $post_id )
92
- ? '' : 'disabled' );
93
94
echo sprintf( '<input %s />', wpcf7_format_atts( $posttitle_atts ) );
95
?>
@@ -181,8 +182,16 @@ if ( $post ) :
181
<div id="postbox-container-2" class="postbox-container">
182
<div id="contact-form-editor">
183
<div class="keyboard-interaction"><?php
184
- /* translators: %s: ◀ ▶ dashicon */
185
- echo sprintf( esc_html( __( '%s keys switch panels', 'contact-form-7' ) ), '<span class="dashicons dashicons-leftright"></span>' );
186
?></div>
187
188
<?php
@@ -194,13 +203,17 @@ if ( $post ) :
194
$panels = array(
195
'form-panel' => array(
196
'title' => __( 'Form', 'contact-form-7' ),
197
- 'callback' => 'wpcf7_editor_panel_form' ),
198
'mail-panel' => array(
199
'title' => __( 'Mail', 'contact-form-7' ),
200
- 'callback' => 'wpcf7_editor_panel_mail' ),
201
'messages-panel' => array(
202
'title' => __( 'Messages', 'contact-form-7' ),
203
- 'callback' => 'wpcf7_editor_panel_messages' ) );
204
205
$additional_settings = trim( $post->prop( 'additional_settings' ) );
206
$additional_settings = explode( "\n", $additional_settings );
@@ -214,7 +227,8 @@ if ( $post ) :
214
__( 'Additional Settings (%d)', 'contact-form-7' ),
215
$additional_settings )
216
: __( 'Additional Settings', 'contact-form-7' ),
217
- 'callback' => 'wpcf7_editor_panel_additional_settings' );
218
}
219
220
$panels = apply_filters( 'wpcf7_editor_panels', $panels );
88
'id' => 'title',
89
'spellcheck' => 'true',
90
'autocomplete' => 'off',
91
+ 'disabled' =>
92
+ current_user_can( 'wpcf7_edit_contact_form', $post_id ) ? '' : 'disabled',
93
+ );
94
95
echo sprintf( '<input %s />', wpcf7_format_atts( $posttitle_atts ) );
96
?>
182
<div id="postbox-container-2" class="postbox-container">
183
<div id="contact-form-editor">
184
<div class="keyboard-interaction"><?php
185
+ echo sprintf(
186
+ /* translators: 1: dashicon, 2: screen reader text for the dashicon */
187
+ esc_html( __( '%1$s %2$s keys switch panels', 'contact-form-7' ) ),
188
+ '<span class="dashicons dashicons-leftright" aria-hidden="true"></span>',
189
+ sprintf(
190
+ '<span class="screen-reader-text">%s</span>',
191
+ /* translators: screen reader text */
192
+ esc_html( __( '(left and right arrow)', 'contact-form-7' ) )
193
+ )
194
+ );
195
?></div>
196
197
<?php
203
$panels = array(
204
'form-panel' => array(
205
'title' => __( 'Form', 'contact-form-7' ),
206
+ 'callback' => 'wpcf7_editor_panel_form',
207
+ ),
208
'mail-panel' => array(
209
'title' => __( 'Mail', 'contact-form-7' ),
210
+ 'callback' => 'wpcf7_editor_panel_mail',
211
+ ),
212
'messages-panel' => array(
213
'title' => __( 'Messages', 'contact-form-7' ),
214
+ 'callback' => 'wpcf7_editor_panel_messages',
215
+ ),
216
+ );
217
218
$additional_settings = trim( $post->prop( 'additional_settings' ) );
219
$additional_settings = explode( "\n", $additional_settings );
227
__( 'Additional Settings (%d)', 'contact-form-7' ),
228
$additional_settings )
229
: __( 'Additional Settings', 'contact-form-7' ),
230
+ 'callback' => 'wpcf7_editor_panel_additional_settings',
231
+ );
232
}
233
234
$panels = apply_filters( 'wpcf7_editor_panels', $panels );
admin/includes/class-contact-forms-list-table.php CHANGED
@@ -135,7 +135,7 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
135
$count_errors, 'contact-form-7' ),
136
number_format_i18n( $count_errors ) );
137
$output .= sprintf(
138
- '<div class="config-error"><span class="dashicons dashicons-warning"></span> %s</div>',
139
$error_notice );
140
}
141
}
135
$count_errors, 'contact-form-7' ),
136
number_format_i18n( $count_errors ) );
137
$output .= sprintf(
138
+ '<div class="config-error"><span class="dashicons dashicons-warning" aria-hidden="true"></span> %s</div>',
139
$error_notice );
140
}
141
}
admin/includes/editor.php CHANGED
@@ -51,15 +51,25 @@ class WPCF7_Editor {
51
}
52
53
function wpcf7_editor_panel_form( $post ) {
54
?>
55
<h2><?php echo esc_html( __( 'Form', 'contact-form-7' ) ); ?></h2>
56
57
<?php
58
$tag_generator = WPCF7_TagGenerator::get_instance();
59
$tag_generator->print_buttons();
60
?>
61
62
<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>
63
<?php
64
}
65
@@ -112,8 +122,22 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
112
?>
113
114
<fieldset>
115
- <legend><?php echo esc_html( __( "In the following fields, you can use these mail-tags:", 'contact-form-7' ) ); ?><br />
116
- <?php $post->suggest_mail_tags( $args['name'] ); ?></legend>
117
<table class="form-table">
118
<tbody>
119
<tr>
@@ -181,6 +205,12 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
181
}
182
183
function wpcf7_editor_panel_messages( $post ) {
184
$messages = wpcf7_messages();
185
186
if ( isset( $messages['captcha_not_match'] )
@@ -191,7 +221,7 @@ function wpcf7_editor_panel_messages( $post ) {
191
?>
192
<h2><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h2>
193
<fieldset>
194
- <legend><?php echo esc_html( __( 'Edit messages used in the following situations.', 'contact-form-7' ) ); ?></legend>
195
<?php
196
197
foreach ( $messages as $key => $arr ) {
51
}
52
53
function wpcf7_editor_panel_form( $post ) {
54
+ $desc_link = wpcf7_link(
55
+ __( 'https://contactform7.com/editing-form-template/', 'contact-form-7' ),
56
+ __( 'Editing Form Template', 'contact-form-7' ) );
57
+ $description = __( "You can edit the form template here. For details, see %s.", 'contact-form-7' );
58
+ $description = sprintf( esc_html( $description ), $desc_link );
59
?>
60
+
61
<h2><?php echo esc_html( __( 'Form', 'contact-form-7' ) ); ?></h2>
62
63
+ <fieldset>
64
+ <legend><?php echo $description; ?></legend>
65
+
66
<?php
67
$tag_generator = WPCF7_TagGenerator::get_instance();
68
$tag_generator->print_buttons();
69
?>
70
71
<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>
72
+ </fieldset>
73
<?php
74
}
75
122
?>
123
124
<fieldset>
125
+ <legend>
126
+ <?php
127
+ $desc_link = wpcf7_link(
128
+ __( 'https://contactform7.com/setting-up-mail/', 'contact-form-7' ),
129
+ __( 'Setting Up Mail', 'contact-form-7' ) );
130
+ $description = __( "You can edit the mail template here. For details, see %s.", 'contact-form-7' );
131
+ $description = sprintf( esc_html( $description ), $desc_link );
132
+ echo $description;
133
+ echo '<br />';
134
+
135
+ echo esc_html( __( "In the following fields, you can use these mail-tags:",
136
+ 'contact-form-7' ) );
137
+ echo '<br />';
138
+ $post->suggest_mail_tags( $args['name'] );
139
+ ?>
140
+ </legend>
141
<table class="form-table">
142
<tbody>
143
<tr>
205
}
206
207
function wpcf7_editor_panel_messages( $post ) {
208
+ $desc_link = wpcf7_link(
209
+ __( 'https://contactform7.com/editing-messages/', 'contact-form-7' ),
210
+ __( 'Editing Messages', 'contact-form-7' ) );
211
+ $description = __( "You can edit messages used in various situations here. For details, see %s.", 'contact-form-7' );
212
+ $description = sprintf( esc_html( $description ), $desc_link );
213
+
214
$messages = wpcf7_messages();
215
216
if ( isset( $messages['captcha_not_match'] )
221
?>
222
<h2><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h2>
223
<fieldset>
224
+ <legend><?php echo $description; ?></legend>
225
<?php
226
227
foreach ( $messages as $key => $arr ) {
admin/includes/welcome-panel.php CHANGED
@@ -19,7 +19,7 @@ function wpcf7_welcome_panel() {
19
<div class="welcome-panel-column-container">
20
21
<div class="welcome-panel-column">
22
- <h3><span class="dashicons dashicons-shield"></span> <?php echo esc_html( __( "Getting spammed? You have protection.", 'contact-form-7' ) ); ?></h3>
23
24
<p><?php echo esc_html( __( "Spammers target everything; your contact forms aren&#8217;t an exception. Before you get spammed, protect your contact forms with the powerful anti-spam features Contact Form 7 provides.", 'contact-form-7' ) ); ?></p>
25
@@ -28,7 +28,7 @@ function wpcf7_welcome_panel() {
28
29
<?php if ( defined( 'FLAMINGO_VERSION' ) ) : ?>
30
<div class="welcome-panel-column">
31
- <h3><span class="dashicons dashicons-megaphone"></span> <?php echo esc_html( __( "Contact Form 7 needs your support.", 'contact-form-7' ) ); ?></h3>
32
33
<p><?php echo esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you.", 'contact-form-7' ) ); ?></p>
34
@@ -38,7 +38,7 @@ function wpcf7_welcome_panel() {
38
</div>
39
<?php else: ?>
40
<div class="welcome-panel-column">
41
- <h3><span class="dashicons dashicons-editor-help"></span> <?php echo esc_html( __( "Before you cry over spilt mail&#8230;", 'contact-form-7' ) ); ?></h3>
42
43
<p><?php echo esc_html( __( "Contact Form 7 doesn&#8217;t store submitted messages anywhere. Therefore, you may lose important messages forever if your mail server has issues or you make a mistake in mail configuration.", 'contact-form-7' ) ); ?></p>
44
19
<div class="welcome-panel-column-container">
20
21
<div class="welcome-panel-column">
22
+ <h3><span class="dashicons dashicons-shield" aria-hidden="true"></span> <?php echo esc_html( __( "Getting spammed? You have protection.", 'contact-form-7' ) ); ?></h3>
23
24
<p><?php echo esc_html( __( "Spammers target everything; your contact forms aren&#8217;t an exception. Before you get spammed, protect your contact forms with the powerful anti-spam features Contact Form 7 provides.", 'contact-form-7' ) ); ?></p>
25
28
29
<?php if ( defined( 'FLAMINGO_VERSION' ) ) : ?>
30
<div class="welcome-panel-column">
31
+ <h3><span class="dashicons dashicons-megaphone" aria-hidden="true"></span> <?php echo esc_html( __( "Contact Form 7 needs your support.", 'contact-form-7' ) ); ?></h3>
32
33
<p><?php echo esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you.", 'contact-form-7' ) ); ?></p>
34
38
</div>
39
<?php else: ?>
40
<div class="welcome-panel-column">
41
+ <h3><span class="dashicons dashicons-editor-help" aria-hidden="true"></span> <?php echo esc_html( __( "Before you cry over spilt mail&#8230;", 'contact-form-7' ) ); ?></h3>
42
43
<p><?php echo esc_html( __( "Contact Form 7 doesn&#8217;t store submitted messages anywhere. Therefore, you may lose important messages forever if your mail server has issues or you make a mistake in mail configuration.", 'contact-form-7' ) ); ?></p>
44
admin/js/scripts.js CHANGED
@@ -157,17 +157,18 @@
157
} );
158
159
$.each( errors[ section ], function( i, val ) {
160
- var $li = $( '<li></li>' ).text( val.message );
161
162
if ( val.link ) {
163
- var $link = $( '<a></a>' ).attr( {
164
- 'href': val.link,
165
- 'class': 'external dashicons dashicons-external'
166
- } ).append( $( '<span></span>' ).attr( {
167
- 'class': 'screen-reader-text'
168
- } ).text( wpcf7.configValidator.howToCorrect ) );
169
-
170
- $li = $li.append( ' ' ).append( $link );
171
}
172
173
$li.appendTo( $list );
@@ -197,7 +198,7 @@
197
key = key.replace( /^mail_\d+\./, 'mail.' );
198
199
if ( key.replace( /\..*#x2F;, '' ) == tab.replace( '-', '_' ) ) {
200
- var $mark = $( '<span class="dashicons dashicons-warning"></span>' );
201
$item.find( 'a.ui-tabs-anchor' ).first().append( $mark );
202
return false;
203
}
@@ -208,7 +209,7 @@
208
209
if ( errorCount[ tab.replace( '-', '_' ) ] ) {
210
$tabPanelError
211
- .append( '<span class="dashicons dashicons-warning"></span> ' );
212
213
if ( 1 < errorCount[ tab.replace( '-', '_' ) ] ) {
214
var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab
@@ -225,7 +226,7 @@
225
if ( errorCount.total ) {
226
var $warning = $( '<div></div>' )
227
.addClass( 'misc-pub-section config-error' )
228
- .append( '<span class="dashicons dashicons-warning"></span> ' );
229
230
if ( 1 < errorCount.total ) {
231
$warning.append(
@@ -235,14 +236,11 @@
235
$warning.append( wpcf7.configValidator.oneError );
236
}
237
238
- var $link = $( '<a></a>' ).attr( {
239
- 'href': wpcf7.configValidator.docUrl,
240
- 'class': 'external dashicons dashicons-external'
241
- } ).append( $( '<span></span>' ).attr( {
242
- 'class': 'screen-reader-text'
243
- } ).text( wpcf7.configValidator.howToCorrect ) );
244
-
245
- $warning.append( ' ' ).append( $link );
246
247
$( '#misc-publishing-actions' ).append( $warning );
248
}
157
} );
158
159
$.each( errors[ section ], function( i, val ) {
160
+ var $li = $( '<li></li>' ).append(
161
+ $( '<span class="dashicons dashicons-warning" aria-hidden="true"></span>' )
162
+ ).append(
163
+ $( '<span class="screen-reader-text"></span>' ).text( wpcf7.configValidator.iconAlt )
164
+ ).append( ' ' );
165
166
if ( val.link ) {
167
+ $li.append(
168
+ $( '<a></a>' ).attr( 'href', val.link ).text( val.message )
169
+ );
170
+ } else {
171
+ $li.text( val.message );
172
}
173
174
$li.appendTo( $list );
198
key = key.replace( /^mail_\d+\./, 'mail.' );
199
200
if ( key.replace( /\..*#x2F;, '' ) == tab.replace( '-', '_' ) ) {
201
+ var $mark = $( '<span class="dashicons dashicons-warning" aria-hidden="true"></span>' );
202
$item.find( 'a.ui-tabs-anchor' ).first().append( $mark );
203
return false;
204
}
209
210
if ( errorCount[ tab.replace( '-', '_' ) ] ) {
211
$tabPanelError
212
+ .append( '<span class="dashicons dashicons-warning" aria-hidden="true"></span> ' );
213
214
if ( 1 < errorCount[ tab.replace( '-', '_' ) ] ) {
215
var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab
226
if ( errorCount.total ) {
227
var $warning = $( '<div></div>' )
228
.addClass( 'misc-pub-section config-error' )
229
+ .append( '<span class="dashicons dashicons-warning" aria-hidden="true"></span> ' );
230
231
if ( 1 < errorCount.total ) {
232
$warning.append(
236
$warning.append( wpcf7.configValidator.oneError );
237
}
238
239
+ $warning.append( '<br />' ).append(
240
+ $( '<a></a>' )
241
+ .attr( 'href', wpcf7.configValidator.docUrl )
242
+ .text( wpcf7.configValidator.howToCorrect )
243
+ );
244
245
$( '#misc-publishing-actions' ).append( $warning );
246
}
admin/js/tag-generator.js CHANGED
@@ -153,7 +153,16 @@
153
} );
154
155
components = $.trim( components.join( ' ' ) );
156
- return '[' + components + ']';
157
};
158
159
wpcf7.taggen.normalize = function( $input ) {
153
} );
154
155
components = $.trim( components.join( ' ' ) );
156
+ components = '[' + components + ']';
157
+
158
+ var content = scope.find( ':input[name="content"]' ).val();
159
+ content = $.trim( content );
160
+
161
+ if ( content ) {
162
+ components += ' ' + content + ' [/' + tagType + ']';
163
+ }
164
+
165
+ return components;
166
};
167
168
wpcf7.taggen.normalize = function( $input ) {
includes/config-validator.php CHANGED
@@ -100,8 +100,9 @@ class WPCF7_ConfigValidator {
100
}
101
102
$error_messages[$section][] = array(
103
- 'message' => esc_html( $message ),
104
- 'link' => esc_url( $link ) );
105
}
106
}
107
@@ -235,31 +236,15 @@ class WPCF7_ConfigValidator {
235
$tagname = $matches[2];
236
$values = $matches[3];
237
238
- if ( ! empty( $values ) ) {
239
- preg_match_all( '/"[^"]*"|\'[^\']*\'/', $values, $matches );
240
- $values = wpcf7_strip_quote_deep( $matches[0] );
241
- }
242
-
243
- $do_not_heat = false;
244
-
245
- if ( preg_match( '/^_raw_(.+)#x2F;', $tagname, $matches ) ) {
246
- $tagname = trim( $matches[1] );
247
- $do_not_heat = true;
248
- }
249
-
250
- $format = '';
251
-
252
- if ( preg_match( '/^_format_(.+)#x2F;', $tagname, $matches ) ) {
253
- $tagname = trim( $matches[1] );
254
- $format = $values[0];
255
- }
256
257
$example_email = 'example@example.com';
258
$example_text = 'example';
259
$example_blank = '';
260
261
$form_tags = $this->contact_form->scan_form_tags(
262
- array( 'name' => $tagname ) );
263
264
if ( $form_tags ) {
265
$form_tag = new WPCF7_FormTag( $form_tags[0] );
@@ -272,7 +257,7 @@ class WPCF7_ConfigValidator {
272
273
if ( wpcf7_form_tag_supports( $form_tag->type, 'selectable-values' ) ) {
274
if ( $form_tag->pipes instanceof WPCF7_Pipes ) {
275
- if ( $do_not_heat ) {
276
$before_pipes = $form_tag->pipes->collect_befores();
277
$last_item = array_pop( $before_pipes );
278
} else {
@@ -296,13 +281,28 @@ class WPCF7_ConfigValidator {
296
return $example_text;
297
}
298
299
- } else {
300
- $tagname = preg_replace( '/^wpcf7\./', '_', $tagname ); // for back-compat
301
302
- if ( '_post_author_email' == $tagname ) {
303
- return $example_email;
304
- } elseif ( '_' == substr( $tagname, 0, 1 ) ) { // maybe special mail tag
305
return $example_text;
306
}
307
}
308
@@ -329,6 +329,8 @@ class WPCF7_ConfigValidator {
329
foreach ( $tags as $tag ) {
330
$is_multiple_controls_container = wpcf7_form_tag_supports(
331
$tag->type, 'multiple-controls-container' );
332
333
if ( $is_multiple_controls_container ) {
334
$fields_count += count( $tag->values );
@@ -336,6 +338,8 @@ class WPCF7_ConfigValidator {
336
if ( $tag->has_option( 'free_text' ) ) {
337
$fields_count += 1;
338
}
339
} elseif ( ! empty( $tag->name ) ) {
340
$fields_count += 1;
341
}
@@ -371,7 +375,7 @@ class WPCF7_ConfigValidator {
371
$ng_names = array();
372
373
foreach ( $ng_named_tags as $tag ) {
374
- $ng_names[] = $tag['name'];
375
}
376
377
if ( $ng_names ) {
@@ -380,7 +384,11 @@ class WPCF7_ConfigValidator {
380
return $this->add_error( $section,
381
self::error_unavailable_names,
382
array(
383
- 'message' => __( "Unavailable names (%names%) are used for form controls.", 'contact-form-7' ),
384
'params' => array( 'names' => implode( ', ', $ng_names ) ),
385
'link' => self::get_doc_link( 'unavailable_names' ),
386
)
@@ -533,7 +541,7 @@ class WPCF7_ConfigValidator {
533
public function detect_file_not_found( $section, $content ) {
534
$path = path_join( WP_CONTENT_DIR, $content );
535
536
- if ( ! @is_readable( $path ) || ! @is_file( $path ) ) {
537
return $this->add_error( $section,
538
self::error_file_not_found,
539
array(
100
}
101
102
$error_messages[$section][] = array(
103
+ 'message' => $message,
104
+ 'link' => esc_url( $link ),
105
+ );
106
}
107
}
108
236
$tagname = $matches[2];
237
$values = $matches[3];
238
239
+ $mail_tag = new WPCF7_MailTag( $tag, $tagname, $values );
240
+ $field_name = $mail_tag->field_name();
241
242
$example_email = 'example@example.com';
243
$example_text = 'example';
244
$example_blank = '';
245
246
$form_tags = $this->contact_form->scan_form_tags(
247
+ array( 'name' => $field_name ) );
248
249
if ( $form_tags ) {
250
$form_tag = new WPCF7_FormTag( $form_tags[0] );
257
258
if ( wpcf7_form_tag_supports( $form_tag->type, 'selectable-values' ) ) {
259
if ( $form_tag->pipes instanceof WPCF7_Pipes ) {
260
+ if ( $mail_tag->get_option( 'do_not_heat' ) ) {
261
$before_pipes = $form_tag->pipes->collect_befores();
262
$last_item = array_pop( $before_pipes );
263
} else {
281
return $example_text;
282
}
283
284
+ } else { // maybe special mail tag
285
+ // for back-compat
286
+ $field_name = preg_replace( '/^wpcf7\./', '_', $field_name );
287
288
+ if ( '_user_agent' == $field_name ) {
289
return $example_text;
290
+
291
+ } elseif ( '_user_email' == $field_name ) {
292
+ return $this->contact_form->is_true( 'subscribers_only' )
293
+ ? $example_email
294
+ : $example_blank;
295
+
296
+ } elseif ( '_user_' == substr( $field_name, 0, 6 ) ) {
297
+ return $this->contact_form->is_true( 'subscribers_only' )
298
+ ? $example_text
299
+ : $example_blank;
300
+
301
+ } elseif ( '_' == substr( $field_name, 0, 1 ) ) {
302
+ return '_email' == substr( $field_name, -6 )
303
+ ? $example_email
304
+ : $example_text;
305
+
306
}
307
}
308
329
foreach ( $tags as $tag ) {
330
$is_multiple_controls_container = wpcf7_form_tag_supports(
331
$tag->type, 'multiple-controls-container' );
332
+ $is_zero_controls_container = wpcf7_form_tag_supports(
333
+ $tag->type, 'zero-controls-container' );
334
335
if ( $is_multiple_controls_container ) {
336
$fields_count += count( $tag->values );
338
if ( $tag->has_option( 'free_text' ) ) {
339
$fields_count += 1;
340
}
341
+ } elseif ( $is_zero_controls_container ) {
342
+ $fields_count += 0;
343
} elseif ( ! empty( $tag->name ) ) {
344
$fields_count += 1;
345
}
375
$ng_names = array();
376
377
foreach ( $ng_named_tags as $tag ) {
378
+ $ng_names[] = sprintf( '"%s"', $tag->name );
379
}
380
381
if ( $ng_names ) {
384
return $this->add_error( $section,
385
self::error_unavailable_names,
386
array(
387
+ /* translators: %names%: a list of form control names */
388
+ 'message' => _n(
389
+ "An unavailable name (%names%) is used for form controls.",
390
+ "Unavailable names (%names%) are used for form controls.",
391
+ count( $ng_names ), 'contact-form-7' ),
392
'params' => array( 'names' => implode( ', ', $ng_names ) ),
393
'link' => self::get_doc_link( 'unavailable_names' ),
394
)
541
public function detect_file_not_found( $section, $content ) {
542
$path = path_join( WP_CONTENT_DIR, $content );
543
544
+ if ( ! is_readable( $path ) || ! is_file( $path ) ) {
545
return $this->add_error( $section,
546
self::error_file_not_found,
547
array(
includes/contact-form.php CHANGED
@@ -343,14 +343,29 @@ class WPCF7_ContactForm {
343
if ( $this->is_posted() ) {
344
$submission = WPCF7_Submission::get_instance();
345
346
- if ( $submission->is( 'validation_failed' ) ) {
347
- $class .= ' invalid';
348
- } elseif ( $submission->is( 'spam' ) ) {
349
- $class .= ' spam';
350
- } elseif ( $submission->is( 'mail_sent' ) ) {
351
- $class .= ' sent';
352
- } elseif ( $submission->is( 'mail_failed' ) ) {
353
- $class .= ' failed';
354
}
355
}
356
@@ -450,14 +465,29 @@ class WPCF7_ContactForm {
450
$submission = WPCF7_Submission::get_instance();
451
$content = $submission->get_response();
452
453
- if ( $submission->is( 'validation_failed' ) ) {
454
- $class .= ' wpcf7-validation-errors';
455
- } elseif ( $submission->is( 'spam' ) ) {
456
- $class .= ' wpcf7-spam-blocked';
457
- } elseif ( $submission->is( 'mail_sent' ) ) {
458
- $class .= ' wpcf7-mail-sent-ok';
459
- } elseif ( $submission->is( 'mail_failed' ) ) {
460
- $class .= ' wpcf7-mail-sent-ng';
461
}
462
} else {
463
$class .= ' wpcf7-display-none';
@@ -556,7 +586,7 @@ class WPCF7_ContactForm {
556
$manager = WPCF7_FormTagsManager::get_instance();
557
$form = $this->prop( 'form' );
558
559
- if ( WPCF7_AUTOP ) {
560
$form = $manager->normalize( $form );
561
$form = wpcf7_autop( $form );
562
}
@@ -599,10 +629,11 @@ class WPCF7_ContactForm {
599
}
600
601
public function collect_mail_tags( $args = '' ) {
602
$args = wp_parse_args( $args, array(
603
'include' => array(),
604
- 'exclude' =>
605
- array( 'acceptance', 'captchac', 'captchar', 'quiz', 'count' ),
606
) );
607
608
$tags = $this->scan_form_tags();
@@ -662,7 +693,10 @@ class WPCF7_ContactForm {
662
663
public function submit( $args = '' ) {
664
$args = wp_parse_args( $args, array(
665
- 'skip_mail' => $this->in_demo_mode() || ! empty( $this->skip_mail ),
666
) );
667
668
if ( $this->is_true( 'subscribers_only' )
@@ -693,22 +727,6 @@ class WPCF7_ContactForm {
693
$result['invalid_fields'] = $submission->get_invalid_fields();
694
}
695
696
- if ( $submission->is( 'mail_sent' ) ) {
697
- $on_sent_ok = $this->additional_setting( 'on_sent_ok', false );
698
-
699
- if ( ! empty( $on_sent_ok ) ) {
700
- $result['scripts_on_sent_ok'] = array_map(
701
- 'wpcf7_strip_quote', $on_sent_ok );
702
- }
703
- }
704
-
705
- $on_submit = $this->additional_setting( 'on_submit', false );
706
-
707
- if ( ! empty( $on_submit ) ) {
708
- $result['scripts_on_submit'] = array_map(
709
- 'wpcf7_strip_quote', $on_submit );
710
- }
711
-
712
do_action( 'wpcf7_submit', $this, $result );
713
714
return $result;
@@ -721,14 +739,20 @@ class WPCF7_ContactForm {
721
$message = isset( $messages[$status] ) ? $messages[$status] : '';
722
723
if ( $filter ) {
724
- $message = wp_strip_all_tags( $message );
725
- $message = wpcf7_mail_replace_tags( $message, array( 'html' => true ) );
726
- $message = apply_filters( 'wpcf7_display_message', $message, $status );
727
}
728
729
return $message;
730
}
731
732
/* Additional settings */
733
734
public function additional_setting( $name, $max = 1 ) {
343
if ( $this->is_posted() ) {
344
$submission = WPCF7_Submission::get_instance();
345
346
+ switch ( $submission->get_status() ) {
347
+ case 'validation_failed':
348
+ $class .= ' invalid';
349
+ break;
350
+ case 'acceptance_missing':
351
+ $class .= ' unaccepted';
352
+ break;
353
+ case 'spam':
354
+ $class .= ' spam';
355
+ break;
356
+ case 'aborted':
357
+ $class .= ' aborted';
358
+ break;
359
+ case 'mail_sent':
360
+ $class .= ' sent';
361
+ break;
362
+ case 'mail_failed':
363
+ $class .= ' failed';
364
+ break;
365
+ default:
366
+ $class .= sprintf( ' custom-%s',
367
+ preg_replace( '/[^0-9a-z]+/i', '-', $submission->get_status() )
368
+ );
369
}
370
}
371
465
$submission = WPCF7_Submission::get_instance();
466
$content = $submission->get_response();
467
468
+ switch ( $submission->get_status() ) {
469
+ case 'validation_failed':
470
+ $class .= ' wpcf7-validation-errors';
471
+ break;
472
+ case 'acceptance_missing':
473
+ $class .= ' wpcf7-acceptance-missing';
474
+ break;
475
+ case 'spam':
476
+ $class .= ' wpcf7-spam-blocked';
477
+ break;
478
+ case 'aborted':
479
+ $class .= ' wpcf7-aborted';
480
+ break;
481
+ case 'mail_sent':
482
+ $class .= ' wpcf7-mail-sent-ok';
483
+ break;
484
+ case 'mail_failed':
485
+ $class .= ' wpcf7-mail-sent-ng';
486
+ break;
487
+ default:
488
+ $class .= sprintf( ' wpcf7-custom-%s',
489
+ preg_replace( '/[^0-9a-z]+/i', '-', $submission->get_status() )
490
+ );
491
}
492
} else {
493
$class .= ' wpcf7-display-none';
586
$manager = WPCF7_FormTagsManager::get_instance();
587
$form = $this->prop( 'form' );
588
589
+ if ( wpcf7_autop_or_not() ) {
590
$form = $manager->normalize( $form );
591
$form = wpcf7_autop( $form );
592
}
629
}
630
631
public function collect_mail_tags( $args = '' ) {
632
+ $manager = WPCF7_FormTagsManager::get_instance();
633
+
634
$args = wp_parse_args( $args, array(
635
'include' => array(),
636
+ 'exclude' => $manager->collect_tag_types( 'not-for-mail' ),
637
) );
638
639
$tags = $this->scan_form_tags();
693
694
public function submit( $args = '' ) {
695
$args = wp_parse_args( $args, array(
696
+ 'skip_mail' =>
697
+ ( $this->in_demo_mode()
698
+ || $this->is_true( 'skip_mail' )
699
+ || ! empty( $this->skip_mail ) ),
700
) );
701
702
if ( $this->is_true( 'subscribers_only' )
727
$result['invalid_fields'] = $submission->get_invalid_fields();
728
}
729
730
do_action( 'wpcf7_submit', $this, $result );
731
732
return $result;
739
$message = isset( $messages[$status] ) ? $messages[$status] : '';
740
741
if ( $filter ) {
742
+ $message = $this->filter_message( $message, $status );
743
}
744
745
return $message;
746
}
747
748
+ public function filter_message( $message, $status = '' ) {
749
+ $message = wp_strip_all_tags( $message );
750
+ $message = wpcf7_mail_replace_tags( $message, array( 'html' => true ) );
751
+ $message = apply_filters( 'wpcf7_display_message', $message, $status );
752
+
753
+ return $message;
754
+ }
755
+
756
/* Additional settings */
757
758
public function additional_setting( $name, $max = 1 ) {
includes/css/styles.css CHANGED
@@ -3,11 +3,6 @@ div.wpcf7 {
3
padding: 0;
4
}
5
6
- div.wpcf7-response-output {
7
- margin: 2em 0.5em 1em;
8
- padding: 0.2em 1em;
9
- }
10
-
11
div.wpcf7 .screen-reader-response {
12
position: absolute;
13
overflow: hidden;
@@ -19,11 +14,18 @@ div.wpcf7 .screen-reader-response {
19
border: 0;
20
}
21
22
div.wpcf7-mail-sent-ok {
23
border: 2px solid #398f14;
24
}
25
26
- div.wpcf7-mail-sent-ng {
27
border: 2px solid #ff0000;
28
}
29
@@ -31,7 +33,8 @@ div.wpcf7-spam-blocked {
31
border: 2px solid #ffa500;
32
}
33
34
- div.wpcf7-validation-errors {
35
border: 2px solid #f7e700;
36
}
37
3
padding: 0;
4
}
5
6
div.wpcf7 .screen-reader-response {
7
position: absolute;
8
overflow: hidden;
14
border: 0;
15
}
16
17
+ div.wpcf7-response-output {
18
+ margin: 2em 0.5em 1em;
19
+ padding: 0.2em 1em;
20
+ border: 2px solid #ff0000;
21
+ }
22
+
23
div.wpcf7-mail-sent-ok {
24
border: 2px solid #398f14;
25
}
26
27
+ div.wpcf7-mail-sent-ng,
28
+ div.wpcf7-aborted {
29
border: 2px solid #ff0000;
30
}
31
33
border: 2px solid #ffa500;
34
}
35
36
+ div.wpcf7-validation-errors,
37
+ div.wpcf7-acceptance-missing {
38
border: 2px solid #f7e700;
39
}
40
includes/form-tags-manager.php CHANGED
@@ -214,27 +214,38 @@ class WPCF7_FormTagsManager {
214
'feature' => '',
215
) );
216
217
- $cond['type'] = array_filter( (array) $cond['type'] );
218
- $cond['name'] = array_filter( (array) $cond['name'] );
219
- $cond['feature'] = is_string( $cond['feature'] )
220
- ? trim( $cond['feature'] ) : '';
221
222
$output = array();
223
224
foreach ( $tags as $tag ) {
225
$tag = new WPCF7_FormTag( $tag );
226
227
- if ( $cond['type'] && ! in_array( $tag->type, $cond['type'], true ) ) {
228
continue;
229
}
230
231
- if ( $cond['name'] && ! in_array( $tag->name, $cond['name'], true ) ) {
232
continue;
233
}
234
235
- if ( $cond['feature']
236
- && ! $this->tag_type_supports( $tag->type, $cond['feature'] ) ) {
237
- continue;
238
}
239
240
$output[] = $tag;
214
'feature' => '',
215
) );
216
217
+ $type = array_filter( (array) $cond['type'] );
218
+ $name = array_filter( (array) $cond['name'] );
219
+ $feature = is_string( $cond['feature'] ) ? trim( $cond['feature'] ) : '';
220
+
221
+ if ( '!' == substr( $feature, 0, 1 ) ) {
222
+ $feature_negative = true;
223
+ $feature = trim( substr( $feature, 1 ) );
224
+ } else {
225
+ $feature_negative = false;
226
+ }
227
228
$output = array();
229
230
foreach ( $tags as $tag ) {
231
$tag = new WPCF7_FormTag( $tag );
232
233
+ if ( $type && ! in_array( $tag->type, $type, true ) ) {
234
continue;
235
}
236
237
+ if ( $name && ! in_array( $tag->name, $name, true ) ) {
238
continue;
239
}
240
241
+ if ( $feature ) {
242
+ if ( ! $this->tag_type_supports( $tag->type, $feature )
243
+ && ! $feature_negative ) {
244
+ continue;
245
+ } elseif ( $this->tag_type_supports( $tag->type, $feature )
246
+ && $feature_negative ) {
247
+ continue;
248
+ }
249
}
250
251
$output[] = $tag;
includes/functions.php CHANGED
@@ -108,6 +108,10 @@ function wpcf7_validate_configuration() {
108
WPCF7_VALIDATE_CONFIGURATION );
109
}
110
111
function wpcf7_load_js() {
112
return apply_filters( 'wpcf7_load_js', WPCF7_LOAD_JS );
113
}
@@ -188,7 +192,8 @@ function wpcf7_register_post_types() {
188
function wpcf7_version( $args = '' ) {
189
$defaults = array(
190
'limit' => -1,
191
- 'only_major' => false );
192
193
$args = wp_parse_args( $args, $defaults );
194
@@ -248,13 +253,13 @@ function wpcf7_enctype_value( $enctype ) {
248
249
function wpcf7_rmdir_p( $dir ) {
250
if ( is_file( $dir ) ) {
251
- if ( ! $result = @unlink( $dir ) ) {
252
- $stat = @stat( $dir );
253
$perms = $stat['mode'];
254
- @chmod( $dir, $perms | 0200 ); // add write for owner
255
256
- if ( ! $result = @unlink( $dir ) ) {
257
- @chmod( $dir, $perms );
258
}
259
}
260
@@ -265,7 +270,7 @@ function wpcf7_rmdir_p( $dir ) {
265
return false;
266
}
267
268
- if ( $handle = @opendir( $dir ) ) {
269
while ( false !== ( $file = readdir( $handle ) ) ) {
270
if ( $file == "." || $file == ".." ) {
271
continue;
@@ -277,7 +282,7 @@ function wpcf7_rmdir_p( $dir ) {
277
closedir( $handle );
278
}
279
280
- return @rmdir( $dir );
281
}
282
283
/* From _http_build_query in wp-includes/functions.php */
108
WPCF7_VALIDATE_CONFIGURATION );
109
}
110
111
+ function wpcf7_autop_or_not() {
112
+ return (bool) apply_filters( 'wpcf7_autop_or_not', WPCF7_AUTOP );
113
+ }
114
+
115
function wpcf7_load_js() {
116
return apply_filters( 'wpcf7_load_js', WPCF7_LOAD_JS );
117
}
192
function wpcf7_version( $args = '' ) {
193
$defaults = array(
194
'limit' => -1,
195
+ 'only_major' => false,
196
+ );
197
198
$args = wp_parse_args( $args, $defaults );
199
253
254
function wpcf7_rmdir_p( $dir ) {
255
if ( is_file( $dir ) ) {
256
+ if ( ! $result = unlink( $dir ) ) {
257
+ $stat = stat( $dir );
258
$perms = $stat['mode'];
259
+ chmod( $dir, $perms | 0200 ); // add write for owner
260
261
+ if ( ! $result = unlink( $dir ) ) {
262
+ chmod( $dir, $perms );
263
}
264
}
265
270
return false;
271
}
272
273
+ if ( $handle = opendir( $dir ) ) {
274
while ( false !== ( $file = readdir( $handle ) ) ) {
275
if ( $file == "." || $file == ".." ) {
276
continue;
282
closedir( $handle );
283
}
284
285
+ return rmdir( $dir );
286
}
287
288
/* From _http_build_query in wp-includes/functions.php */
includes/js/scripts.js CHANGED
@@ -237,6 +237,7 @@
237
var ajaxSuccess = function( data, status, xhr, $form ) {
238
detail.id = $( data.into ).attr( 'id' );
239
detail.status = data.status;
240
241
var $message = $( '.wpcf7-response-output', $form );
242
@@ -255,6 +256,12 @@
255
256
wpcf7.triggerEvent( data.into, 'invalid', detail );
257
break;
258
case 'spam':
259
$message.addClass( 'wpcf7-spam-blocked' );
260
$form.addClass( 'spam' );
@@ -268,31 +275,33 @@
268
269
wpcf7.triggerEvent( data.into, 'spam', detail );
270
break;
271
case 'mail_sent':
272
$message.addClass( 'wpcf7-mail-sent-ok' );
273
$form.addClass( 'sent' );
274
275
- if ( data.onSentOk ) {
276
- $.each( data.onSentOk, function( i, n ) { eval( n ) } );
277
- }
278
-
279
wpcf7.triggerEvent( data.into, 'mailsent', detail );
280
break;
281
case 'mail_failed':
282
- case 'acceptance_missing':
283
- default:
284
$message.addClass( 'wpcf7-mail-sent-ng' );
285
$form.addClass( 'failed' );
286
287
wpcf7.triggerEvent( data.into, 'mailfailed', detail );
288
}
289
290
wpcf7.refill( $form, data );
291
292
- if ( data.onSubmit ) {
293
- $.each( data.onSubmit, function( i, n ) { eval( n ) } );
294
- }
295
-
296
wpcf7.triggerEvent( data.into, 'submit', detail );
297
298
if ( 'mail_sent' == data.status ) {
@@ -380,13 +389,16 @@
380
381
$submit.prop( 'disabled', false );
382
383
- $( 'input:checkbox.wpcf7-acceptance', $form ).each( function() {
384
- var $a = $( this );
385
386
- if ( $a.hasClass( 'wpcf7-invert' ) && $a.is( ':checked' )
387
- || ! $a.hasClass( 'wpcf7-invert' ) && ! $a.is( ':checked' ) ) {
388
- $submit.prop( 'disabled', true );
389
- return false;
390
}
391
} );
392
};
237
var ajaxSuccess = function( data, status, xhr, $form ) {
238
detail.id = $( data.into ).attr( 'id' );
239
detail.status = data.status;
240
+ detail.apiResponse = data;
241
242
var $message = $( '.wpcf7-response-output', $form );
243
256
257
wpcf7.triggerEvent( data.into, 'invalid', detail );
258
break;
259
+ case 'acceptance_missing':
260
+ $message.addClass( 'wpcf7-acceptance-missing' );
261
+ $form.addClass( 'unaccepted' );
262
+
263
+ wpcf7.triggerEvent( data.into, 'unaccepted', detail );
264
+ break;
265
case 'spam':
266
$message.addClass( 'wpcf7-spam-blocked' );
267
$form.addClass( 'spam' );
275
276
wpcf7.triggerEvent( data.into, 'spam', detail );
277
break;
278
+ case 'aborted':
279
+ $message.addClass( 'wpcf7-aborted' );
280
+ $form.addClass( 'aborted' );
281
+
282
+ wpcf7.triggerEvent( data.into, 'aborted', detail );
283
+ break;
284
case 'mail_sent':
285
$message.addClass( 'wpcf7-mail-sent-ok' );
286
$form.addClass( 'sent' );
287
288
wpcf7.triggerEvent( data.into, 'mailsent', detail );
289
break;
290
case 'mail_failed':
291
$message.addClass( 'wpcf7-mail-sent-ng' );
292
$form.addClass( 'failed' );
293
294
wpcf7.triggerEvent( data.into, 'mailfailed', detail );
295
+ break;
296
+ default:
297
+ var customStatusClass = 'custom-'
298
+ + data.status.replace( /[^0-9a-z]+/i, '-' );
299
+ $message.addClass( 'wpcf7-' + customStatusClass );
300
+ $form.addClass( customStatusClass );
301
}
302
303
wpcf7.refill( $form, data );
304
305
wpcf7.triggerEvent( data.into, 'submit', detail );
306
307
if ( 'mail_sent' == data.status ) {
389
390
$submit.prop( 'disabled', false );
391
392
+ $( '.wpcf7-acceptance', $form ).each( function() {
393
+ var $span = $( this );
394
+ var $input = $( 'input:checkbox', $span );
395
396
+ if ( ! $span.hasClass( 'optional' ) ) {
397
+ if ( $span.hasClass( 'invert' ) && $input.is( ':checked' )
398
+ || ! $span.hasClass( 'invert' ) && ! $input.is( ':checked' ) ) {
399
+ $submit.prop( 'disabled', true );
400
+ return false;
401
+ }
402
}
403
} );
404
};
includes/mail.php CHANGED
@@ -5,6 +5,7 @@ class WPCF7_Mail {
5
private static $current = null;
6
7
private $name = '';
8
private $template = array();
9
private $use_html = false;
10
private $exclude_blank = false;
@@ -31,6 +32,11 @@ class WPCF7_Mail {
31
'additional_headers' => '',
32
'attachments' => '',
33
) );
34
}
35
36
public function name() {
@@ -60,9 +66,20 @@ class WPCF7_Mail {
60
}
61
62
private function htmlize( $body ) {
63
$header = apply_filters( 'wpcf7_mail_html_header',
64
'<!doctype html>
65
- <html xmlns="http://www.w3.org/1999/xhtml">
66
<head>
67
<title>' . esc_html( $this->get( 'subject', true ) ) . '</title>
68
</head>
@@ -157,7 +174,7 @@ class WPCF7_Mail {
157
158
$path = path_join( WP_CONTENT_DIR, $line );
159
160
- if ( @is_readable( $path ) && @is_file( $path ) ) {
161
$attachments[] = $path;
162
}
163
}
@@ -282,37 +299,23 @@ class WPCF7_MailTaggedText {
282
$tagname = $matches[2];
283
$values = $matches[3];
284
285
- if ( ! empty( $values ) ) {
286
- preg_match_all( '/"[^"]*"|\'[^\']*\'/', $values, $matches );
287
- $values = wpcf7_strip_quote_deep( $matches[0] );
288
- }
289
-
290
- $do_not_heat = false;
291
-
292
- if ( preg_match( '/^_raw_(.+)#x2F;', $tagname, $matches ) ) {
293
- $tagname = trim( $matches[1] );
294
- $do_not_heat = true;
295
- }
296
-
297
- $format = '';
298
-
299
- if ( preg_match( '/^_format_(.+)#x2F;', $tagname, $matches ) ) {
300
- $tagname = trim( $matches[1] );
301
- $format = $values[0];
302
- }
303
304
$submission = WPCF7_Submission::get_instance();
305
- $submitted = $submission ? $submission->get_posted_data( $tagname ) : null;
306
307
if ( null !== $submitted ) {
308
309
- if ( $do_not_heat ) {
310
- $submitted = isset( $_POST[$tagname] ) ? $_POST[$tagname] : '';
311
}
312
313
$replaced = $submitted;
314
315
- if ( ! empty( $format ) ) {
316
$replaced = $this->format( $replaced, $format );
317
}
318
@@ -323,8 +326,16 @@ class WPCF7_MailTaggedText {
323
$replaced = wptexturize( $replaced );
324
}
325
326
- $replaced = apply_filters( 'wpcf7_mail_tag_replaced',
327
- $replaced, $submitted, $html );
328
329
$replaced = wp_unslash( trim( $replaced ) );
330
@@ -332,9 +343,10 @@ class WPCF7_MailTaggedText {
332
return $replaced;
333
}
334
335
- $special = apply_filters( 'wpcf7_special_mail_tags', '', $tagname, $html );
336
337
- if ( ! empty( $special ) ) {
338
$this->replaced_tags[$tag] = $special;
339
return $special;
340
}
@@ -355,90 +367,73 @@ class WPCF7_MailTaggedText {
355
}
356
}
357
358
- /* Special Mail Tags */
359
-
360
- add_filter( 'wpcf7_special_mail_tags', 'wpcf7_special_mail_tag', 10, 3 );
361
362
- function wpcf7_special_mail_tag( $output, $name, $html ) {
363
- $name = preg_replace( '/^wpcf7\./', '_', $name ); // for back-compat
364
365
- $submission = WPCF7_Submission::get_instance();
366
367
- if ( ! $submission ) {
368
- return $output;
369
- }
370
371
- if ( '_remote_ip' == $name ) {
372
- if ( $remote_ip = $submission->get_meta( 'remote_ip' ) ) {
373
- return $remote_ip;
374
- } else {
375
- return '';
376
}
377
- }
378
379
- if ( '_user_agent' == $name ) {
380
- if ( $user_agent = $submission->get_meta( 'user_agent' ) ) {
381
- return $html ? esc_html( $user_agent ) : $user_agent;
382
- } else {
383
- return '';
384
}
385
- }
386
387
- if ( '_url' == $name ) {
388
- if ( $url = $submission->get_meta( 'url' ) ) {
389
- return esc_url( $url );
390
- } else {
391
- return '';
392
}
393
}
394
395
- if ( '_date' == $name || '_time' == $name ) {
396
- if ( $timestamp = $submission->get_meta( 'timestamp' ) ) {
397
- if ( '_date' == $name ) {
398
- return date_i18n( get_option( 'date_format' ), $timestamp );
399
- }
400
-
401
- if ( '_time' == $name ) {
402
- return date_i18n( get_option( 'time_format' ), $timestamp );
403
- }
404
- }
405
-
406
- return '';
407
}
408
409
- if ( '_post_' == substr( $name, 0, 6 ) ) {
410
- $post_id = (int) $submission->get_meta( 'container_post_id' );
411
-
412
- if ( $post = get_post( $post_id ) ) {
413
- if ( '_post_id' == $name ) {
414
- return (string) $post->ID;
415
- }
416
-
417
- if ( '_post_name' == $name ) {
418
- return $post->post_name;
419
- }
420
421
- if ( '_post_title' == $name ) {
422
- return $html ? esc_html( $post->post_title ) : $post->post_title;
423
- }
424
425
- if ( '_post_url' == $name ) {
426
- return get_permalink( $post->ID );
427
- }
428
429
- $user = new WP_User( $post->post_author );
430
431
- if ( '_post_author' == $name ) {
432
- return $user->display_name;
433
- }
434
435
- if ( '_post_author_email' == $name ) {
436
- return $user->user_email;
437
}
438
}
439
440
- return '';
441
}
442
-
443
- return $output;
444
}
5
private static $current = null;
6
7
private $name = '';
8
+ private $locale = '';
9
private $template = array();
10
private $use_html = false;
11
private $exclude_blank = false;
32
'additional_headers' => '',
33
'attachments' => '',
34
) );
35
+
36
+ if ( $submission = WPCF7_Submission::get_instance() ) {
37
+ $contact_form = $submission->get_contact_form();
38
+ $this->locale = $contact_form->locale();
39
+ }
40
}
41
42
public function name() {
66
}
67
68
private function htmlize( $body ) {
69
+ if ( $this->locale ) {
70
+ $lang_atts = sprintf( ' %s',
71
+ wpcf7_format_atts( array(
72
+ 'dir' => wpcf7_is_rtl( $this->locale ) ? 'rtl' : 'ltr',
73
+ 'lang' => str_replace( '_', '-', $this->locale ),
74
+ ) )
75
+ );
76
+ } else {
77
+ $lang_atts = '';
78
+ }
79
+
80
$header = apply_filters( 'wpcf7_mail_html_header',
81
'<!doctype html>
82
+ <html xmlns="http://www.w3.org/1999/xhtml"' . $lang_atts . '>
83
<head>
84
<title>' . esc_html( $this->get( 'subject', true ) ) . '</title>
85
</head>
174
175
$path = path_join( WP_CONTENT_DIR, $line );
176
177
+ if ( is_readable( $path ) && is_file( $path ) ) {
178
$attachments[] = $path;
179
}
180
}
299
$tagname = $matches[2];
300
$values = $matches[3];
301
302
+ $mail_tag = new WPCF7_MailTag( $tag, $tagname, $values );
303
+ $field_name = $mail_tag->field_name();
304
305
$submission = WPCF7_Submission::get_instance();
306
+ $submitted = $submission
307
+ ? $submission->get_posted_data( $field_name )
308
+ : null;
309
310
if ( null !== $submitted ) {
311
312
+ if ( $mail_tag->get_option( 'do_not_heat' ) ) {
313
+ $submitted = isset( $_POST[$field_name] ) ? $_POST[$field_name] : '';
314
}
315
316
$replaced = $submitted;
317
318
+ if ( $format = $mail_tag->get_option( 'format' ) ) {
319
$replaced = $this->format( $replaced, $format );
320
}
321
326
$replaced = wptexturize( $replaced );
327
}
328
329
+ if ( $form_tag = $mail_tag->corresponding_form_tag() ) {
330
+ $type = $form_tag->type;
331
+
332
+ $replaced = apply_filters(
333
+ "wpcf7_mail_tag_replaced_{$type}", $replaced,
334
+ $submitted, $html, $mail_tag );
335
+ }
336
+
337
+ $replaced = apply_filters( 'wpcf7_mail_tag_replaced', $replaced,
338
+ $submitted, $html, $mail_tag );
339
340
$replaced = wp_unslash( trim( $replaced ) );
341
343
return $replaced;
344
}
345
346
+ $special = apply_filters( 'wpcf7_special_mail_tags', null,
347
+ $mail_tag->tag_name(), $html, $mail_tag );
348
349
+ if ( null !== $special ) {
350
$this->replaced_tags[$tag] = $special;
351
return $special;
352
}
367
}
368
}
369
370
+ class WPCF7_MailTag {
371
372
+ private $tag;
373
+ private $tagname = '';
374
+ private $name = '';
375
+ private $options = array();
376
+ private $values = array();
377
+ private $form_tag = null;
378
379
+ public function __construct( $tag, $tagname, $values ) {
380
+ $this->tag = $tag;
381
+ $this->name = $this->tagname = $tagname;
382
383
+ $this->options = array(
384
+ 'do_not_heat' => false,
385
+ 'format' => '',
386
+ );
387
388
+ if ( ! empty( $values ) ) {
389
+ preg_match_all( '/"[^"]*"|\'[^\']*\'/', $values, $matches );
390
+ $this->values = wpcf7_strip_quote_deep( $matches[0] );
391
}
392
393
+ if ( preg_match( '/^_raw_(.+)#x2F;', $tagname, $matches ) ) {
394
+ $this->name = trim( $matches[1] );
395
+ $this->options['do_not_heat'] = true;
396
}
397
398
+ if ( preg_match( '/^_format_(.+)#x2F;', $tagname, $matches ) ) {
399
+ $this->name = trim( $matches[1] );
400
+ $this->options['format'] = $this->values[0];
401
}
402
}
403
404
+ public function tag_name() {
405
+ return $this->tagname;
406
}
407
408
+ public function field_name() {
409
+ return $this->name;
410
+ }
411
412
+ public function get_option( $option ) {
413
+ return $this->options[$option];
414
+ }
415
416
+ public function values() {
417
+ return $this->values;
418
+ }
419
420
+ public function corresponding_form_tag() {
421
+ if ( $this->form_tag instanceof WPCF7_FormTag ) {
422
+ return $this->form_tag;
423
+ }
424
425
+ if ( $submission = WPCF7_Submission::get_instance() ) {
426
+ $contact_form = $submission->get_contact_form();
427
+ $tags = $contact_form->scan_form_tags( array(
428
+ 'name' => $this->name,
429
+ 'feature' => '! zero-controls-container',
430
+ ) );
431
432
+ if ( $tags ) {
433
+ $this->form_tag = $tags[0];
434
}
435
}
436
437
+ return $this->form_tag;
438
}
439
}
includes/rest-api.php CHANGED
@@ -302,14 +302,6 @@ function wpcf7_rest_create_feedback( WP_REST_Request $request ) {
302
$response['invalidFields'] = $invalid_fields;
303
}
304
305
- if ( ! empty( $result['scripts_on_sent_ok'] ) ) {
306
- $response['onSentOk'] = $result['scripts_on_sent_ok'];
307
- }
308
-
309
- if ( ! empty( $result['scripts_on_submit'] ) ) {
310
- $response['onSubmit'] = $result['scripts_on_submit'];
311
- }
312
-
313
$response = apply_filters( 'wpcf7_ajax_json_echo', $response, $result );
314
315
return rest_ensure_response( $response );
302
$response['invalidFields'] = $invalid_fields;
303
}
304
305
$response = apply_filters( 'wpcf7_ajax_json_echo', $response, $result );
306
307
return rest_ensure_response( $response );
includes/special-mail-tags.php ADDED
@@ -0,0 +1,165 @@
1
+ <?php
2
+ /**
3
+ ** Special Mail Tags
4
+ ** https://contactform7.com/special-mail-tags/
5
+ **/
6
+
7
+ add_filter( 'wpcf7_special_mail_tags', 'wpcf7_special_mail_tag', 10, 3 );
8
+
9
+ function wpcf7_special_mail_tag( $output, $name, $html ) {
10
+ $name = preg_replace( '/^wpcf7\./', '_', $name ); // for back-compat
11
+
12
+ $submission = WPCF7_Submission::get_instance();
13
+
14
+ if ( ! $submission ) {
15
+ return $output;
16
+ }
17
+
18
+ if ( '_remote_ip' == $name ) {
19
+ if ( $remote_ip = $submission->get_meta( 'remote_ip' ) ) {
20
+ return $remote_ip;
21
+ } else {
22
+ return '';
23
+ }
24
+ }
25
+
26
+ if ( '_user_agent' == $name ) {
27
+ if ( $user_agent = $submission->get_meta( 'user_agent' ) ) {
28
+ return $html ? esc_html( $user_agent ) : $user_agent;
29
+ } else {
30
+ return '';
31
+ }
32
+ }
33
+
34
+ if ( '_url' == $name ) {
35
+ if ( $url = $submission->get_meta( 'url' ) ) {
36
+ return esc_url( $url );
37
+ } else {
38
+ return '';
39
+ }
40
+ }
41
+
42
+ if ( '_date' == $name || '_time' == $name ) {
43
+ if ( $timestamp = $submission->get_meta( 'timestamp' ) ) {
44
+ if ( '_date' == $name ) {
45
+ return date_i18n( get_option( 'date_format' ), $timestamp );
46
+ }
47
+
48
+ if ( '_time' == $name ) {
49
+ return date_i18n( get_option( 'time_format' ), $timestamp );
50
+ }
51
+ }
52
+
53
+ return '';
54
+ }
55
+
56
+ if ( '_invalid_fields' == $name ) {
57
+ return count( $submission->get_invalid_fields() );
58
+ }
59
+
60
+ return $output;
61
+ }
62
+
63
+ add_filter( 'wpcf7_special_mail_tags', 'wpcf7_post_related_smt', 10, 3 );
64
+
65
+ function wpcf7_post_related_smt( $output, $name, $html ) {
66
+ if ( '_post_' != substr( $name, 0, 6 ) ) {
67
+ return $output;
68
+ }
69
+
70
+ $submission = WPCF7_Submission::get_instance();
71
+
72
+ if ( ! $submission ) {
73
+ return $output;
74
+ }
75
+
76
+ $post_id = (int) $submission->get_meta( 'container_post_id' );
77
+
78
+ if ( ! $post_id || ! $post = get_post( $post_id ) ) {
79
+ return '';
80
+ }
81
+
82
+ if ( '_post_id' == $name ) {
83
+ return (string) $post->ID;
84
+ }
85
+
86
+ if ( '_post_name' == $name ) {
87
+ return $post->post_name;
88
+ }
89
+
90
+ if ( '_post_title' == $name ) {
91
+ return $html ? esc_html( $post->post_title ) : $post->post_title;
92
+ }
93
+
94
+ if ( '_post_url' == $name ) {
95
+ return get_permalink( $post->ID );
96
+ }
97
+
98
+ $user = new WP_User( $post->post_author );
99
+
100
+ if ( '_post_author' == $name ) {
101
+ return $user->display_name;
102
+ }
103
+
104
+ if ( '_post_author_email' == $name ) {
105
+ return $user->user_email;
106
+ }
107
+
108
+ return $output;
109
+ }
110
+
111
+ add_filter( 'wpcf7_special_mail_tags', 'wpcf7_site_related_smt', 10, 3 );
112
+
113
+ function wpcf7_site_related_smt( $output, $name, $html ) {
114
+ $filter = $html ? 'display' : 'raw';
115
+
116
+ if ( '_site_title' == $name ) {
117
+ return get_bloginfo( 'name', $filter );
118
+ }
119
+
120
+ if ( '_site_description' == $name ) {
121
+ return get_bloginfo( 'description', $filter );
122
+ }
123
+
124
+ if ( '_site_url' == $name ) {
125
+ return get_bloginfo( 'url', $filter );
126
+ }
127
+
128
+ if ( '_site_admin_email' == $name ) {
129
+ return get_bloginfo( 'admin_email', $filter );
130
+ }
131
+
132
+ return $output;
133
+ }
134
+
135
+ add_filter( 'wpcf7_special_mail_tags', 'wpcf7_user_related_smt', 10, 3 );
136
+
137
+ function wpcf7_user_related_smt( $output, $name, $html ) {
138
+ if ( '_user_' != substr( $name, 0, 6 ) || '_user_agent' == $name ) {
139
+ return $output;
140
+ }
141
+
142
+ $submission = WPCF7_Submission::get_instance();
143
+
144
+ if ( ! $submission ) {
145
+ return $output;
146
+ }
147
+
148
+ $user_id = (int) $submission->get_meta( 'current_user_id' );
149
+
150
+ if ( ! $user_id ) {
151
+ return '';
152
+ }
153
+
154
+ $primary_props = array( 'user_login', 'user_email', 'user_url' );
155
+ $opt = ltrim( $name, '_' );
156
+ $opt = in_array( $opt, $primary_props ) ? $opt : substr( $opt, 5 );
157
+
158
+ $user = new WP_User( $user_id );
159
+
160
+ if ( $user->has_prop( $opt ) ) {
161
+ return $user->get( $opt );
162
+ }
163
+
164
+ return '';
165
+ }
includes/submission.php CHANGED
@@ -12,6 +12,7 @@ class WPCF7_Submission {
12
private $response = '';
13
private $invalid_fields = array();
14
private $meta = array();
15
16
private function __construct() {}
17
@@ -45,6 +46,15 @@ class WPCF7_Submission {
45
return $this->status;
46
}
47
48
public function is( $status ) {
49
return $this->status == $status;
50
}
@@ -53,6 +63,15 @@ class WPCF7_Submission {
53
return $this->response;
54
}
55
56
public function get_invalid_field( $name ) {
57
if ( isset( $this->invalid_fields[$name] ) ) {
58
return $this->invalid_fields[$name];
@@ -85,35 +104,37 @@ class WPCF7_Submission {
85
$tags = $this->contact_form->scan_form_tags();
86
87
foreach ( (array) $tags as $tag ) {
88
- if ( empty( $tag['name'] ) ) {
89
continue;
90
}
91
92
- $name = $tag['name'];
93
- $value = '';
94
95
if ( isset( $posted_data[$name] ) ) {
96
- $value = $posted_data[$name];
97
}
98
99
- $pipes = $tag['pipes'];
100
-
101
if ( WPCF7_USE_PIPE
102
&& $pipes instanceof WPCF7_Pipes
103
&& ! $pipes->zero() ) {
104
- if ( is_array( $value) ) {
105
- $new_value = array();
106
107
- foreach ( $value as $v ) {
108
- $new_value[] = $pipes->do_pipe( wp_unslash( $v ) );
109
}
110
-
111
- $value = $new_value;
112
} else {
113
- $value = $pipes->do_pipe( wp_unslash( $value ) );
114
}
115
}
116
117
$posted_data[$name] = $value;
118
}
119
@@ -148,31 +169,43 @@ class WPCF7_Submission {
148
isset( $_POST['_wpcf7_unit_tag'] ) ? $_POST['_wpcf7_unit_tag'] : '',
149
'container_post_id' => isset( $_POST['_wpcf7_container_post'] )
150
? (int) $_POST['_wpcf7_container_post'] : 0,
151
);
152
153
$contact_form = $this->contact_form;
154
155
if ( ! $this->validate() ) { // Validation error occured
156
- $this->status = 'validation_failed';
157
- $this->response = $contact_form->message( 'validation_error' );
158
159
} elseif ( ! $this->accepted() ) { // Not accepted terms
160
- $this->status = 'acceptance_missing';
161
- $this->response = $contact_form->message( 'accept_terms' );
162
163
} elseif ( $this->spam() ) { // Spam!
164
- $this->status = 'spam';
165
- $this->response = $contact_form->message( 'spam' );
166
167
} elseif ( $this->mail() ) {
168
- $this->status = 'mail_sent';
169
- $this->response = $contact_form->message( 'mail_sent_ok' );
170
171
do_action( 'wpcf7_mail_sent', $contact_form );
172
173
} else {
174
- $this->status = 'mail_failed';
175
- $this->response = $contact_form->message( 'mail_sent_ng' );
176
177
do_action( 'wpcf7_mail_failed', $contact_form );
178
}
@@ -222,7 +255,7 @@ class WPCF7_Submission {
222
$tags = $this->contact_form->scan_form_tags();
223
224
foreach ( $tags as $tag ) {
225
- $type = $tag['type'];
226
$result = apply_filters( "wpcf7_validate_{$type}", $result, $tag );
227
}
228
@@ -234,7 +267,16 @@ class WPCF7_Submission {
234
}
235
236
private function accepted() {
237
- return apply_filters( 'wpcf7_acceptance', true );
238
}
239
240
private function spam() {
@@ -282,12 +324,23 @@ class WPCF7_Submission {
282
283
/* Mail */
284
285
private function mail() {
286
$contact_form = $this->contact_form;
287
288
- do_action( 'wpcf7_before_send_mail', $contact_form );
289
-
290
- $skip_mail = apply_filters( 'wpcf7_skip_mail', $this->skip_mail, $contact_form );
291
292
if ( $skip_mail ) {
293
return true;
@@ -330,7 +383,7 @@ class WPCF7_Submission {
330
public function remove_uploaded_files() {
331
foreach ( (array) $this->uploaded_files as $name => $path ) {
332
wpcf7_rmdir_p( $path );
333
- @rmdir( dirname( $path ) ); // remove parent dir if it's removable (empty).
334
}
335
}
336
12
private $response = '';
13
private $invalid_fields = array();
14
private $meta = array();
15
+ private $consent = array();
16
17
private function __construct() {}
18
46
return $this->status;
47
}
48
49
+ public function set_status( $status ) {
50
+ if ( preg_match( '/^[a-z][0-9a-z_]+#x2F;', $status ) ) {
51
+ $this->status = $status;
52
+ return true;
53
+ }
54
+
55
+ return false;
56
+ }
57
+
58
public function is( $status ) {
59
return $this->status == $status;
60
}
63
return $this->response;
64
}
65
66
+ public function set_response( $response ) {
67
+ $this->response = $response;
68
+ return true;
69
+ }
70
+
71
+ public function get_contact_form() {
72
+ return $this->contact_form;
73
+ }
74
+
75
public function get_invalid_field( $name ) {
76
if ( isset( $this->invalid_fields[$name] ) ) {
77
return $this->invalid_fields[$name];
104
$tags = $this->contact_form->scan_form_tags();
105
106
foreach ( (array) $tags as $tag ) {
107
+ if ( empty( $tag->name ) ) {
108
continue;
109
}
110
111
+ $type = $tag->type;
112
+ $name = $tag->name;
113
+ $pipes = $tag->pipes;
114
+
115
+ $value_orig = $value = '';
116
117
if ( isset( $posted_data[$name] ) ) {
118
+ $value_orig = $value = $posted_data[$name];
119
}
120
121
if ( WPCF7_USE_PIPE
122
&& $pipes instanceof WPCF7_Pipes
123
&& ! $pipes->zero() ) {
124
+ if ( is_array( $value_orig ) ) {
125
+ $value = array();
126
127
+ foreach ( $value_orig as $v ) {
128
+ $value[] = $pipes->do_pipe( wp_unslash( $v ) );
129
}
130
} else {
131
+ $value = $pipes->do_pipe( wp_unslash( $value_orig ) );
132
}
133
}
134
135
+ $value = apply_filters( "wpcf7_posted_data_{$type}", $value,
136
+ $value_orig, $tag );
137
+
138
$posted_data[$name] = $value;
139
}
140
169
isset( $_POST['_wpcf7_unit_tag'] ) ? $_POST['_wpcf7_unit_tag'] : '',
170
'container_post_id' => isset( $_POST['_wpcf7_container_post'] )
171
? (int) $_POST['_wpcf7_container_post'] : 0,
172
+ 'current_user_id' => get_current_user_id(),
173
);
174
175
$contact_form = $this->contact_form;
176
177
if ( ! $this->validate() ) { // Validation error occured
178
+ $this->set_status( 'validation_failed' );
179
+ $this->set_response( $contact_form->message( 'validation_error' ) );
180
181
} elseif ( ! $this->accepted() ) { // Not accepted terms
182
+ $this->set_status( 'acceptance_missing' );
183
+ $this->set_response( $contact_form->message( 'accept_terms' ) );
184
185
} elseif ( $this->spam() ) { // Spam!
186
+ $this->set_status( 'spam' );
187
+ $this->set_response( $contact_form->message( 'spam' ) );
188
+
189
+ } elseif ( ! $this->before_send_mail() ) {
190
+ if ( 'init' == $this->get_status() ) {
191
+ $this->set_status( 'aborted' );
192
+ }
193
+
194
+ if ( '' === $this->get_response() ) {
195
+ $this->set_response( $contact_form->filter_message(
196
+ __( "Sending mail has been aborted.", 'contact-form-7' ) )
197
+ );
198
+ }
199
200
} elseif ( $this->mail() ) {
201
+ $this->set_status( 'mail_sent' );
202
+ $this->set_response( $contact_form->message( 'mail_sent_ok' ) );
203
204
do_action( 'wpcf7_mail_sent', $contact_form );
205
206
} else {
207
+ $this->set_status( 'mail_failed' );
208
+ $this->set_response( $contact_form->message( 'mail_sent_ng' ) );
209
210
do_action( 'wpcf7_mail_failed', $contact_form );
211
}
255
$tags = $this->contact_form->scan_form_tags();
256
257
foreach ( $tags as $tag ) {
258
+ $type = $tag->type;
259
$result = apply_filters( "wpcf7_validate_{$type}", $result, $tag );
260
}
261
267
}
268
269
private function accepted() {
270
+ return apply_filters( 'wpcf7_acceptance', true, $this );
271
+ }
272
+
273
+ public function add_consent( $name, $conditions ) {
274
+ $this->consent[$name] = $conditions;
275
+ return true;
276
+ }
277
+
278
+ public function collect_consent() {
279
+ return (array) $this->consent;
280
}
281
282
private function spam() {
324
325
/* Mail */
326
327
+ private function before_send_mail() {
328
+ $abort = false;
329
+
330
+ do_action_ref_array( 'wpcf7_before_send_mail', array(
331
+ $this->contact_form,
332
+ &$abort,
333
+ $this,
334
+ ) );
335
+
336
+ return ! $abort;
337
+ }
338
+
339
private function mail() {
340
$contact_form = $this->contact_form;
341
342
+ $skip_mail = apply_filters( 'wpcf7_skip_mail',
343
+ $this->skip_mail, $contact_form );
344
345
if ( $skip_mail ) {
346
return true;
383
public function remove_uploaded_files() {
384
foreach ( (array) $this->uploaded_files as $name => $path ) {
385
wpcf7_rmdir_p( $path );
386
+ rmdir( dirname( $path ) ); // remove parent dir if it's removable (empty).
387
}
388
}
389
license.txt CHANGED
@@ -1,4 +1,4 @@
1
- Contact Form 7 WordPress Plugin, 2007-2017 Takayuki Miyoshi
2
Contact Form 7 is distributed under the terms of the GNU GPL
3
4
This program is free software; you can redistribute it and/or modify
@@ -14,3 +14,345 @@ GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1
+ Contact Form 7 WordPress Plugin, 2007-2018 Takayuki Miyoshi
2
Contact Form 7 is distributed under the terms of the GNU GPL
3
4
This program is free software; you can redistribute it and/or modify
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
19
+
20
+ GNU GENERAL PUBLIC LICENSE
21
+ Version 2, June 1991
22
+
23
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
24
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25
+ Everyone is permitted to copy and distribute verbatim copies
26
+ of this license document, but changing it is not allowed.
27
+
28
+ Preamble
29
+
30
+ The licenses for most software are designed to take away your
31
+ freedom to share and change it. By contrast, the GNU General Public
32
+ License is intended to guarantee your freedom to share and change free
33
+ software--to make sure the software is free for all its users. This
34
+ General Public License applies to most of the Free Software
35
+ Foundation's software and to any other program whose authors commit to
36
+ using it. (Some other Free Software Foundation software is covered by
37
+ the GNU Lesser General Public License instead.) You can apply it to
38
+ your programs, too.
39
+
40
+ When we speak of free software, we are referring to freedom, not
41
+ price. Our General Public Licenses are designed to make sure that you
42
+ have the freedom to distribute copies of free software (and charge for
43
+ this service if you wish), that you receive source code or can get it
44
+ if you want it, that you can change the software or use pieces of it
45
+ in new free programs; and that you know you can do these things.
46
+
47
+ To protect your rights, we need to make restrictions that forbid
48
+ anyone to deny you these rights or to ask you to surrender the rights.
49
+ These restrictions translate to certain responsibilities for you if you
50
+ distribute copies of the software, or if you modify it.
51
+
52
+ For example, if you distribute copies of such a program, whether
53
+ gratis or for a fee, you must give the recipients all the rights that
54
+ you have. You must make sure that they, too, receive or can get the
55
+ source code. And you must show them these terms so they know their
56
+ rights.
57
+
58
+ We protect your rights with two steps: (1) copyright the software, and
59
+ (2) offer you this license which gives you legal permission to copy,
60
+ distribute and/or modify the software.
61
+
62
+ Also, for each author's protection and ours, we want to make certain
63
+ that everyone understands that there is no warranty for this free
64
+ software. If the software is modified by someone else and passed on, we
65
+ want its recipients to know that what they have is not the original, so
66
+ that any problems introduced by others will not reflect on the original
67
+ authors' reputations.
68
+
69
+ Finally, any free program is threatened constantly by software
70
+ patents. We wish to avoid the danger that redistributors of a free
71
+ program will individually obtain patent licenses, in effect making the
72
+ program proprietary. To prevent this, we have made it clear that any
73
+ patent must be licensed for everyone's free use or not licensed at all.
74
+
75
+ The precise terms and conditions for copying, distribution and
76
+ modification follow.
77
+
78
+ GNU GENERAL PUBLIC LICENSE
79
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
80
+
81
+ 0. This License applies to any program or other work which contains
82
+ a notice placed by the copyright holder saying it may be distributed
83
+ under the terms of this General Public License. The "Program", below,
84
+ refers to any such program or work, and a "work based on the Program"
85
+ means either the Program or any derivative work under copyright law:
86
+ that is to say, a work containing the Program or a portion of it,
87
+ either verbatim or with modifications and/or translated into another
88
+ language. (Hereinafter, translation is included without limitation in
89
+ the term "modification".) Each licensee is addressed as "you".
90
+
91
+ Activities other than copying, distribution and modification are not
92
+ covered by this License; they are outside its scope. The act of
93
+ running the Program is not restricted, and the output from the Program
94
+ is covered only if its contents constitute a work based on the
95
+ Program (independent of having been made by running the Program).
96
+ Whether that is true depends on what the Program does.
97
+
98
+ 1. You may copy and distribute verbatim copies of the Program's
99
+ source code as you receive it, in any medium, provided that you
100
+ conspicuously and appropriately publish on each copy an appropriate
101
+ copyright notice and disclaimer of warranty; keep intact all the
102
+ notices that refer to this License and to the absence of any warranty;
103
+ and give any other recipients of the Program a copy of this License
104
+ along with the Program.
105
+
106
+ You may charge a fee for the physical act of transferring a copy, and
107
+ you may at your option offer warranty protection in exchange for a fee.
108
+
109
+ 2. You may modify your copy or copies of the Program or any portion
110
+ of it, thus forming a work based on the Program, and copy and
111
+ distribute such modifications or work under the terms of Section 1
112
+ above, provided that you also meet all of these conditions:
113
+
114
+ a) You must cause the modified files to carry prominent notices
115
+ stating that you changed the files and the date of any change.
116
+
117
+ b) You must cause any work that you distribute or publish, that in
118
+ whole or in part contains or is derived from the Program or any
119
+ part thereof, to be licensed as a whole at no charge to all third
120
+ parties under the terms of this License.
121
+
122
+ c) If the modified program normally reads commands interactively
123
+ when run, you must cause it, when started running for such
124
+ interactive use in the most ordinary way, to print or display an
125
+ announcement including an appropriate copyright notice and a
126
+ notice that there is no warranty (or else, saying that you provide
127
+ a warranty) and that users may redistribute the program under
128
+ these conditions, and telling the user how to view a copy of this
129
+ License. (Exception: if the Program itself is interactive but
130
+ does not normally print such an announcement, your work based on
131
+ the Program is not required to print an announcement.)
132
+
133
+ These requirements apply to the modified work as a whole. If
134
+ identifiable sections of that work are not derived from the Program,
135
+ and can be reasonably considered independent and separate works in
136
+ themselves, then this License, and its terms, do not apply to those
137
+ sections when you distribute them as separate works. But when you
138
+ distribute the same sections as part of a whole which is a work based
139
+ on the Program, the distribution of the whole must be on the terms of
140
+ this License, whose permissions for other licensees extend to the
141
+ entire whole, and thus to each and every part regardless of who wrote it.
142
+
143
+ Thus, it is not the intent of this section to claim rights or contest
144
+ your rights to work written entirely by you; rather, the intent is to
145
+ exercise the right to control the distribution of derivative or
146
+ collective works based on the Program.
147
+
148
+ In addition, mere aggregation of another work not based on the Program
149
+ with the Program (or with a work based on the Program) on a volume of
150
+ a storage or distribution medium does not bring the other work under
151
+ the scope of this License.
152
+
153
+ 3. You may copy and distribute the Program (or a work based on it,
154
+ under Section 2) in object code or executable form under the terms of
155
+ Sections 1 and 2 above provided that you also do one of the following:
156
+
157
+ a) Accompany it with the complete corresponding machine-readable
158
+ source code, which must be distributed under the terms of Sections
159
+ 1 and 2 above on a medium customarily used for software interchange; or,
160
+
161
+ b) Accompany it with a written offer, valid for at least three
162
+ years, to give any third party, for a charge no more than your
163
+ cost of physically performing source distribution, a complete
164
+ machine-readable copy of the corresponding source code, to be
165
+ distributed under the terms of Sections 1 and 2 above on a medium
166
+ customarily used for software interchange; or,
167
+
168
+ c) Accompany it with the information you received as to the offer
169
+ to distribute corresponding source code. (This alternative is
170
+ allowed only for noncommercial distribution and only if you
171
+ received the program in object code or executable form with such
172
+ an offer, in accord with Subsection b above.)
173
+
174
+ The source code for a work means the preferred form of the work for
175
+ making modifications to it. For an executable work, complete source
176
+ code means all the source code for all modules it contains, plus any
177
+ associated interface definition files, plus the scripts used to
178
+ control compilation and installation of the executable. However, as a
179
+ special exception, the source code distributed need not include
180
+ anything that is normally distributed (in either source or binary
181
+ form) with the major components (compiler, kernel, and so on) of the
182
+ operating system on which the executable runs, unless that component
183
+ itself accompanies the executable.
184
+
185
+ If distribution of executable or object code is made by offering
186
+ access to copy from a designated place, then offering equivalent
187
+ access to copy the source code from the same place counts as
188
+ distribution of the source code, even though third parties are not
189
+ compelled to copy the source along with the object code.
190
+
191
+ 4. You may not copy, modify, sublicense, or distribute the Program
192
+ except as expressly provided under this License. Any attempt
193
+ otherwise to copy, modify, sublicense or distribute the Program is
194
+ void, and will automatically terminate your rights under this License.
195
+ However, parties who have received copies, or rights, from you under
196
+ this License will not have their licenses terminated so long as such
197
+ parties remain in full compliance.
198
+
199
+ 5. You are not required to accept this License, since you have not
200
+ signed it. However, nothing else grants you permission to modify or
201
+ distribute the Program or its derivative works. These actions are
202
+ prohibited by law if you do not accept this License. Therefore, by
203
+ modifying or distributing the Program (or any work based on the
204
+ Program), you indicate your acceptance of this License to do so, and
205
+ all its terms and conditions for copying, distributing or modifying
206
+ the Program or works based on it.
207
+
208
+ 6. Each time you redistribute the Program (or any work based on the
209
+ Program), the recipient automatically receives a license from the
210
+ original licensor to copy, distribute or modify the Program subject to
211
+ these terms and conditions. You may not impose any further
212
+ restrictions on the recipients' exercise of the rights granted herein.
213
+ You are not responsible for enforcing compliance by third parties to
214
+ this License.
215
+
216
+ 7. If, as a consequence of a court judgment or allegation of patent
217
+ infringement or for any other reason (not limited to patent issues),
218
+ conditions are imposed on you (whether by court order, agreement or
219
+ otherwise) that contradict the conditions of this License, they do not
220
+ excuse you from the conditions of this License. If you cannot
221
+ distribute so as to satisfy simultaneously your obligations under this
222
+ License and any other pertinent obligations, then as a consequence you
223
+ may not distribute the Program at all. For example, if a patent
224
+ license would not permit royalty-free redistribution of the Program by
225
+ all those who receive copies directly or indirectly through you, then
226
+ the only way you could satisfy both it and this License would be to
227
+ refrain entirely from distribution of the Program.
228
+
229
+ If any portion of this section is held invalid or unenforceable under
230
+ any particular circumstance, the balance of the section is intended to
231
+ apply and the section as a whole is intended to apply in other
232
+ circumstances.
233
+
234
+ It is not the purpose of this section to induce you to infringe any
235
+ patents or other property right claims or to contest validity of any
236
+ such claims; this section has the sole purpose of protecting the
237
+ integrity of the free software distribution system, which is
238
+ implemented by public license practices. Many people have made
239
+ generous contributions to the wide range of software distributed
240
+ through that system in reliance on consistent application of that
241
+ system; it is up to the author/donor to decide if he or she is willing
242
+ to distribute software through any other system and a licensee cannot
243
+ impose that choice.
244
+
245
+ This section is intended to make thoroughly clear what is believed to
246
+ be a consequence of the rest of this License.
247
+
248
+ 8. If the distribution and/or use of the Program is restricted in
249
+ certain countries either by patents or by copyrighted interfaces, the
250
+ original copyright holder who places the Program under this License
251
+ may add an explicit geographical distribution limitation excluding
252
+ those countries, so that distribution is permitted only in or among
253
+ countries not thus excluded. In such case, this License incorporates
254
+ the limitation as if written in the body of this License.
255
+
256
+ 9. The Free Software Foundation may publish revised and/or new versions
257
+ of the General Public License from time to time. Such new versions will
258
+ be similar in spirit to the present version, but may differ in detail to
259
+ address new problems or concerns.
260
+
261
+ Each version is given a distinguishing version number. If the Program
262
+ specifies a version number of this License which applies to it and "any
263
+ later version", you have the option of following the terms and conditions
264
+ either of that version or of any later version published by the Free
265
+ Software Foundation. If the Program does not specify a version number of
266
+ this License, you may choose any version ever published by the Free Software
267
+ Foundation.
268
+
269
+ 10. If you wish to incorporate parts of the Program into other free
270
+ programs whose distribution conditions are different, write to the author
271
+ to ask for permission. For software which is copyrighted by the Free
272
+ Software Foundation, write to the Free Software Foundation; we sometimes
273
+ make exceptions for this. Our decision will be guided by the two goals
274
+ of preserving the free status of all derivatives of our free software and
275
+ of promoting the sharing and reuse of software generally.
276
+
277
+ NO WARRANTY
278
+
279
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
280
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
281
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
282
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
283
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
284
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
285
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
286
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
287
+ REPAIR OR CORRECTION.
288
+
289
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
290
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
291
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
292
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
293
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
294
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
295
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
296
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
297
+ POSSIBILITY OF SUCH DAMAGES.
298
+
299
+ END OF TERMS AND CONDITIONS
300
+
301
+ How to Apply These Terms to Your New Programs
302
+
303
+ If you develop a new program, and you want it to be of the greatest
304
+ possible use to the public, the best way to achieve this is to make it
305
+ free software which everyone can redistribute and change under these terms.
306
+
307
+ To do so, attach the following notices to the program. It is safest
308
+ to attach them to the start of each source file to most effectively
309
+ convey the exclusion of warranty; and each file should have at least
310
+ the "copyright" line and a pointer to where the full notice is found.
311
+
312
+ <one line to give the program's name and a brief idea of what it does.>
313
+ Copyright (C) <year> <name of author>
314
+
315
+ This program is free software; you can redistribute it and/or modify
316
+ it under the terms of the GNU General Public License as published by
317
+ the Free Software Foundation; either version 2 of the License, or
318
+ (at your option) any later version.
319
+
320
+ This program is distributed in the hope that it will be useful,
321
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
322
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
323
+ GNU General Public License for more details.
324