Version Description
Download this release
Release Info
Developer | takayukister |
Plugin | Contact Form 7 |
Version | 5.0 |
Comparing to | |
See all releases |
Code changes from version 4.9.2 to 5.0
- admin/admin.php +14 -5
- admin/css/styles.css +21 -14
- admin/edit-contact-form.php +22 -8
- admin/includes/class-contact-forms-list-table.php +1 -1
- admin/includes/editor.php +33 -3
- admin/includes/welcome-panel.php +3 -3
- admin/js/scripts.js +18 -20
- admin/js/tag-generator.js +10 -1
- includes/config-validator.php +38 -30
- includes/contact-form.php +63 -39
- includes/css/styles.css +10 -7
- includes/form-tags-manager.php +20 -9
- includes/functions.php +13 -8
- includes/js/scripts.js +28 -16
- includes/mail.php +87 -92
- includes/rest-api.php +0 -8
- includes/special-mail-tags.php +165 -0
- includes/submission.php +82 -29
- license.txt +343 -1
- modules/acceptance.php +101 -24
- modules/akismet.php +3 -10
- modules/count.php +7 -1
- modules/file.php +96 -46
- modules/flamingo.php +72 -20
- modules/quiz.php +1 -0
- modules/really-simple-captcha.php +56 -22
- readme.txt +18 -48
- settings.php +1 -0
- wp-contact-form-7.php +3 -3
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
|
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 |
-
|
545 |
-
|
|
|
|
|
|
|
|
|
|
|
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:
|
75 |
-
padding:
|
76 |
margin: 0;
|
77 |
}
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
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: #
|
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' =>
|
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 |
-
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
116 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
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’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…", 'contact-form-7' ) ); ?></h3>
|
42 |
|
43 |
<p><?php echo esc_html( __( "Contact Form 7 doesn’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’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…", 'contact-form-7' ) ); ?></h3>
|
42 |
|
43 |
<p><?php echo esc_html( __( "Contact Form 7 doesn’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>' ).
|
|
|
|
|
|
|
|
|
161 |
|
162 |
if ( val.link ) {
|
163 |
-
|
164 |
-
'href'
|
165 |
-
|
166 |
-
|
167 |
-
|
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( /\..*$/, '' ) == 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 |
-
|
239 |
-
'
|
240 |
-
|
241 |
-
|
242 |
-
|
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( /\..*$/, '' ) == 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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' =>
|
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 |
-
|
239 |
-
|
240 |
-
$values = wpcf7_strip_quote_deep( $matches[0] );
|
241 |
-
}
|
242 |
-
|
243 |
-
$do_not_heat = false;
|
244 |
-
|
245 |
-
if ( preg_match( '/^_raw_(.+)$/', $tagname, $matches ) ) {
|
246 |
-
$tagname = trim( $matches[1] );
|
247 |
-
$do_not_heat = true;
|
248 |
-
}
|
249 |
-
|
250 |
-
$format = '';
|
251 |
-
|
252 |
-
if ( preg_match( '/^_format_(.+)$/', $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' => $
|
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 |
-
|
|
|
301 |
|
302 |
-
if ( '
|
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
|
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 |
-
|
|
|
|
|
|
|
|
|
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 ( !
|
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 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
}
|
355 |
}
|
356 |
|
@@ -450,14 +465,29 @@ class WPCF7_ContactForm {
|
|
450 |
$submission = WPCF7_Submission::get_instance();
|
451 |
$content = $submission->get_response();
|
452 |
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 (
|
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' =>
|
|
|
|
|
|
|
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 =
|
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 |
-
$
|
218 |
-
$
|
219 |
-
$cond['feature']
|
220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
$output = array();
|
223 |
|
224 |
foreach ( $tags as $tag ) {
|
225 |
$tag = new WPCF7_FormTag( $tag );
|
226 |
|
227 |
-
if ( $
|
228 |
continue;
|
229 |
}
|
230 |
|
231 |
-
if ( $
|
232 |
continue;
|
233 |
}
|
234 |
|
235 |
-
if ( $
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
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 =
|
252 |
-
$stat =
|
253 |
$perms = $stat['mode'];
|
254 |
-
|
255 |
|
256 |
-
if ( ! $result =
|
257 |
-
|
258 |
}
|
259 |
}
|
260 |
|
@@ -265,7 +270,7 @@ function wpcf7_rmdir_p( $dir ) {
|
|
265 |
return false;
|
266 |
}
|
267 |
|
268 |
-
if ( $handle =
|
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
|
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 |
-
$( '
|
384 |
-
var $
|
|
|
385 |
|
386 |
-
if ( $
|
387 |
-
|
388 |
-
$
|
389 |
-
|
|
|
|
|
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 (
|
161 |
$attachments[] = $path;
|
162 |
}
|
163 |
}
|
@@ -282,37 +299,23 @@ class WPCF7_MailTaggedText {
|
|
282 |
$tagname = $matches[2];
|
283 |
$values = $matches[3];
|
284 |
|
285 |
-
|
286 |
-
|
287 |
-
$values = wpcf7_strip_quote_deep( $matches[0] );
|
288 |
-
}
|
289 |
-
|
290 |
-
$do_not_heat = false;
|
291 |
-
|
292 |
-
if ( preg_match( '/^_raw_(.+)$/', $tagname, $matches ) ) {
|
293 |
-
$tagname = trim( $matches[1] );
|
294 |
-
$do_not_heat = true;
|
295 |
-
}
|
296 |
-
|
297 |
-
$format = '';
|
298 |
-
|
299 |
-
if ( preg_match( '/^_format_(.+)$/', $tagname, $matches ) ) {
|
300 |
-
$tagname = trim( $matches[1] );
|
301 |
-
$format = $values[0];
|
302 |
-
}
|
303 |
|
304 |
$submission = WPCF7_Submission::get_instance();
|
305 |
-
$submitted = $submission
|
|
|
|
|
306 |
|
307 |
if ( null !== $submitted ) {
|
308 |
|
309 |
-
if ( $do_not_heat ) {
|
310 |
-
$submitted = isset( $_POST[$
|
311 |
}
|
312 |
|
313 |
$replaced = $submitted;
|
314 |
|
315 |
-
if (
|
316 |
$replaced = $this->format( $replaced, $format );
|
317 |
}
|
318 |
|
@@ -323,8 +326,16 @@ class WPCF7_MailTaggedText {
|
|
323 |
$replaced = wptexturize( $replaced );
|
324 |
}
|
325 |
|
326 |
-
$
|
327 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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',
|
|
|
336 |
|
337 |
-
if (
|
338 |
$this->replaced_tags[$tag] = $special;
|
339 |
return $special;
|
340 |
}
|
@@ -355,90 +367,73 @@ class WPCF7_MailTaggedText {
|
|
355 |
}
|
356 |
}
|
357 |
|
358 |
-
|
359 |
-
|
360 |
-
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_special_mail_tag', 10, 3 );
|
361 |
|
362 |
-
|
363 |
-
$
|
|
|
|
|
|
|
|
|
364 |
|
365 |
-
$
|
|
|
|
|
366 |
|
367 |
-
|
368 |
-
|
369 |
-
|
|
|
370 |
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
} else {
|
375 |
-
return '';
|
376 |
}
|
377 |
-
}
|
378 |
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
} else {
|
383 |
-
return '';
|
384 |
}
|
385 |
-
}
|
386 |
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
} else {
|
391 |
-
return '';
|
392 |
}
|
393 |
}
|
394 |
|
395 |
-
|
396 |
-
|
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 |
-
|
410 |
-
|
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 |
-
|
422 |
-
|
423 |
-
|
424 |
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
|
429 |
-
|
|
|
|
|
|
|
430 |
|
431 |
-
|
432 |
-
|
433 |
-
|
|
|
|
|
|
|
434 |
|
435 |
-
if (
|
436 |
-
|
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_(.+)$/', $tagname, $matches ) ) {
|
394 |
+
$this->name = trim( $matches[1] );
|
395 |
+
$this->options['do_not_heat'] = true;
|
|
|
|
|
396 |
}
|
|
|
397 |
|
398 |
+
if ( preg_match( '/^_format_(.+)$/', $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
|
89 |
continue;
|
90 |
}
|
91 |
|
92 |
-
$
|
93 |
-
$
|
|
|
|
|
|
|
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( $
|
105 |
-
$
|
106 |
|
107 |
-
foreach ( $
|
108 |
-
$
|
109 |
}
|
110 |
-
|
111 |
-
$value = $new_value;
|
112 |
} else {
|
113 |
-
$value = $pipes->do_pipe( wp_unslash( $
|
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->
|
157 |
-
$this->
|
158 |
|
159 |
} elseif ( ! $this->accepted() ) { // Not accepted terms
|
160 |
-
$this->
|
161 |
-
$this->
|
162 |
|
163 |
} elseif ( $this->spam() ) { // Spam!
|
164 |
-
$this->
|
165 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
} elseif ( $this->mail() ) {
|
168 |
-
$this->
|
169 |
-
$this->
|
170 |
|
171 |
do_action( 'wpcf7_mail_sent', $contact_form );
|
172 |
|
173 |
} else {
|
174 |
-
$this->
|
175 |
-
$this->
|
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
|
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 |
-
|
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 |
-
|
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_]+$/', $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-
|
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 |
+
|
325 |
+
You should have received a copy of the GNU General Public License along
|
326 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
327 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
328 |
+
|
329 |
+
Also add information on how to contact you by electronic and paper mail.
|
330 |
+
|
331 |
+
If the program is interactive, make it output a short notice like this
|
332 |
+
when it starts in an interactive mode:
|
333 |
+
|
334 |
+
Gnomovision version 69, Copyright (C) year name of author
|
335 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
336 |
+
This is free software, and you are welcome to redistribute it
|
337 |
+
under certain conditions; type `show c' for details.
|
338 |
+
|
339 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
340 |
+
parts of the General Public License. Of course, the commands you use may
|
341 |
+
be called something other than `show w' and `show c'; they could even be
|
342 |
+
mouse-clicks or menu items--whatever suits your program.
|
343 |
+
|
344 |
+
You should also get your employer (if you work as a programmer) or your
|
345 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
346 |
+
necessary. Here is a sample; alter the names:
|
347 |
+
|
348 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
349 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
350 |
+
|
351 |
+
<signature of Ty Coon>, 1 April 1989
|
352 |
+
Ty Coon, President of Vice
|
353 |
+
|
354 |
+
This General Public License does not permit incorporating your program into
|
355 |
+
proprietary programs. If your program is a subroutine library, you may
|
356 |
+
consider it more useful to permit linking proprietary applications with the
|
357 |
+
library. If this is what you want to do, use the GNU Lesser General
|
358 |
+
Public License instead of this License.
|
modules/acceptance.php
CHANGED
@@ -31,30 +31,50 @@ function wpcf7_acceptance_form_tag_handler( $tag ) {
|
|
31 |
}
|
32 |
|
33 |
if ( $tag->has_option( 'invert' ) ) {
|
34 |
-
$class .= '
|
35 |
}
|
36 |
|
37 |
-
$
|
|
|
|
|
38 |
|
39 |
-
$atts
|
40 |
-
|
41 |
-
$
|
|
|
|
|
|
|
|
|
42 |
|
43 |
if ( $tag->has_option( 'default:on' ) ) {
|
44 |
-
$
|
45 |
}
|
46 |
|
47 |
-
$
|
|
|
|
|
|
|
|
|
48 |
|
49 |
-
$
|
50 |
-
$atts['name'] = $tag->name;
|
51 |
-
$atts['value'] = '1';
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
$atts = wpcf7_format_atts( $atts );
|
54 |
|
55 |
$html = sprintf(
|
56 |
-
'<span class="wpcf7-form-control-wrap %1$s"><
|
57 |
-
sanitize_html_class( $tag->name ), $atts, $validation_error );
|
58 |
|
59 |
return $html;
|
60 |
}
|
@@ -62,13 +82,18 @@ function wpcf7_acceptance_form_tag_handler( $tag ) {
|
|
62 |
|
63 |
/* Validation filter */
|
64 |
|
65 |
-
add_filter( 'wpcf7_validate_acceptance',
|
|
|
66 |
|
67 |
function wpcf7_acceptance_validation_filter( $result, $tag ) {
|
68 |
if ( ! wpcf7_acceptance_as_validation() ) {
|
69 |
return $result;
|
70 |
}
|
71 |
|
|
|
|
|
|
|
|
|
72 |
$name = $tag->name;
|
73 |
$value = ( ! empty( $_POST[$name] ) ? 1 : 0 );
|
74 |
|
@@ -84,18 +109,13 @@ function wpcf7_acceptance_validation_filter( $result, $tag ) {
|
|
84 |
|
85 |
/* Acceptance filter */
|
86 |
|
87 |
-
add_filter( 'wpcf7_acceptance', 'wpcf7_acceptance_filter' );
|
88 |
|
89 |
-
function wpcf7_acceptance_filter( $accepted ) {
|
90 |
-
|
91 |
-
return $accepted;
|
92 |
-
}
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
foreach ( $fes as $fe ) {
|
97 |
-
$name = $fe['name'];
|
98 |
-
$options = (array) $fe['options'];
|
99 |
|
100 |
if ( empty( $name ) ) {
|
101 |
continue;
|
@@ -103,7 +123,21 @@ function wpcf7_acceptance_filter( $accepted ) {
|
|
103 |
|
104 |
$value = ( ! empty( $_POST[$name] ) ? 1 : 0 );
|
105 |
|
106 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
if ( $invert && $value || ! $invert && ! $value ) {
|
109 |
$accepted = false;
|
@@ -131,6 +165,44 @@ function wpcf7_acceptance_as_validation() {
|
|
131 |
return $contact_form->is_true( 'acceptance_as_validation' );
|
132 |
}
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
/* Tag generator */
|
136 |
|
@@ -162,6 +234,11 @@ function wpcf7_tag_generator_acceptance( $contact_form, $args = '' ) {
|
|
162 |
<td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
|
163 |
</tr>
|
164 |
|
|
|
|
|
|
|
|
|
|
|
165 |
<tr>
|
166 |
<th scope="row"><?php echo esc_html( __( 'Options', 'contact-form-7' ) ); ?></th>
|
167 |
<td>
|
31 |
}
|
32 |
|
33 |
if ( $tag->has_option( 'invert' ) ) {
|
34 |
+
$class .= ' invert';
|
35 |
}
|
36 |
|
37 |
+
if ( $tag->has_option( 'optional' ) ) {
|
38 |
+
$class .= ' optional';
|
39 |
+
}
|
40 |
|
41 |
+
$atts = $item_atts = array();
|
42 |
+
|
43 |
+
$item_atts['type'] = 'checkbox';
|
44 |
+
$item_atts['name'] = $tag->name;
|
45 |
+
$item_atts['value'] = '1';
|
46 |
+
$item_atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
|
47 |
+
$item_atts['aria-invalid'] = $validation_error ? 'true' : 'false';
|
48 |
|
49 |
if ( $tag->has_option( 'default:on' ) ) {
|
50 |
+
$item_atts['checked'] = 'checked';
|
51 |
}
|
52 |
|
53 |
+
$item_atts = wpcf7_format_atts( $item_atts );
|
54 |
+
|
55 |
+
$content = empty( $tag->content )
|
56 |
+
? (string) reset( $tag->values )
|
57 |
+
: $tag->content;
|
58 |
|
59 |
+
$content = trim( $content );
|
|
|
|
|
60 |
|
61 |
+
if ( $content ) {
|
62 |
+
$html = sprintf(
|
63 |
+
'<span class="wpcf7-list-item"><label><input %1$s /><span class="wpcf7-list-item-label">%2$s</span></label></span>',
|
64 |
+
$item_atts, $content );
|
65 |
+
} else {
|
66 |
+
$html = sprintf(
|
67 |
+
'<span class="wpcf7-list-item"><input %1$s /></span>',
|
68 |
+
$item_atts );
|
69 |
+
}
|
70 |
+
|
71 |
+
$atts['class'] = $tag->get_class_option( $class );
|
72 |
+
$atts['id'] = $tag->get_id_option();
|
73 |
$atts = wpcf7_format_atts( $atts );
|
74 |
|
75 |
$html = sprintf(
|
76 |
+
'<span class="wpcf7-form-control-wrap %1$s"><span %2$s>%3$s</span>%4$s</span>',
|
77 |
+
sanitize_html_class( $tag->name ), $atts, $html, $validation_error );
|
78 |
|
79 |
return $html;
|
80 |
}
|
82 |
|
83 |
/* Validation filter */
|
84 |
|
85 |
+
add_filter( 'wpcf7_validate_acceptance',
|
86 |
+
'wpcf7_acceptance_validation_filter', 10, 2 );
|
87 |
|
88 |
function wpcf7_acceptance_validation_filter( $result, $tag ) {
|
89 |
if ( ! wpcf7_acceptance_as_validation() ) {
|
90 |
return $result;
|
91 |
}
|
92 |
|
93 |
+
if ( $tag->has_option( 'optional' ) ) {
|
94 |
+
return $result;
|
95 |
+
}
|
96 |
+
|
97 |
$name = $tag->name;
|
98 |
$value = ( ! empty( $_POST[$name] ) ? 1 : 0 );
|
99 |
|
109 |
|
110 |
/* Acceptance filter */
|
111 |
|
112 |
+
add_filter( 'wpcf7_acceptance', 'wpcf7_acceptance_filter', 10, 2 );
|
113 |
|
114 |
+
function wpcf7_acceptance_filter( $accepted, $submission ) {
|
115 |
+
$tags = wpcf7_scan_form_tags( array( 'type' => 'acceptance' ) );
|
|
|
|
|
116 |
|
117 |
+
foreach ( $tags as $tag ) {
|
118 |
+
$name = $tag->name;
|
|
|
|
|
|
|
119 |
|
120 |
if ( empty( $name ) ) {
|
121 |
continue;
|
123 |
|
124 |
$value = ( ! empty( $_POST[$name] ) ? 1 : 0 );
|
125 |
|
126 |
+
$content = empty( $tag->content )
|
127 |
+
? (string) reset( $tag->values )
|
128 |
+
: $tag->content;
|
129 |
+
|
130 |
+
$content = trim( $content );
|
131 |
+
|
132 |
+
if ( $value && $content ) {
|
133 |
+
$submission->add_consent( $name, $content );
|
134 |
+
}
|
135 |
+
|
136 |
+
if ( $tag->has_option( 'optional' ) ) {
|
137 |
+
continue;
|
138 |
+
}
|
139 |
+
|
140 |
+
$invert = $tag->has_option( 'invert' );
|
141 |
|
142 |
if ( $invert && $value || ! $invert && ! $value ) {
|
143 |
$accepted = false;
|
165 |
return $contact_form->is_true( 'acceptance_as_validation' );
|
166 |
}
|
167 |
|
168 |
+
add_filter( 'wpcf7_mail_tag_replaced_acceptance',
|
169 |
+
'wpcf7_acceptance_mail_tag', 10, 4 );
|
170 |
+
|
171 |
+
function wpcf7_acceptance_mail_tag( $replaced, $submitted, $html, $mail_tag ) {
|
172 |
+
$form_tag = $mail_tag->corresponding_form_tag();
|
173 |
+
|
174 |
+
if ( ! $form_tag ) {
|
175 |
+
return $replaced;
|
176 |
+
}
|
177 |
+
|
178 |
+
if ( ! empty( $submitted ) ) {
|
179 |
+
$replaced = __( 'Consented', 'contact-form-7' );
|
180 |
+
} else {
|
181 |
+
$replaced = __( 'Not consented', 'contact-form-7' );
|
182 |
+
}
|
183 |
+
|
184 |
+
$content = empty( $form_tag->content )
|
185 |
+
? (string) reset( $form_tag->values )
|
186 |
+
: $form_tag->content;
|
187 |
+
|
188 |
+
if ( ! $html ) {
|
189 |
+
$content = wp_strip_all_tags( $content );
|
190 |
+
}
|
191 |
+
|
192 |
+
$content = trim( $content );
|
193 |
+
|
194 |
+
if ( $content ) {
|
195 |
+
/* translators: 1: 'Consented' or 'Not consented', 2: conditions */
|
196 |
+
$replaced = sprintf(
|
197 |
+
_x( '%1$s: %2$s', 'mail output for acceptance checkboxes',
|
198 |
+
'contact-form-7' ),
|
199 |
+
$replaced,
|
200 |
+
$content );
|
201 |
+
}
|
202 |
+
|
203 |
+
return $replaced;
|
204 |
+
}
|
205 |
+
|
206 |
|
207 |
/* Tag generator */
|
208 |
|
234 |
<td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
|
235 |
</tr>
|
236 |
|
237 |
+
<tr>
|
238 |
+
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-content' ); ?>"><?php echo esc_html( __( 'Condition', 'contact-form-7' ) ); ?></label></th>
|
239 |
+
<td><input type="text" name="content" class="oneline large-text" id="<?php echo esc_attr( $args['content'] . '-content' ); ?>" /></td>
|
240 |
+
</tr>
|
241 |
+
|
242 |
<tr>
|
243 |
<th scope="row"><?php echo esc_html( __( 'Options', 'contact-form-7' ) ); ?></th>
|
244 |
<td>
|
modules/akismet.php
CHANGED
@@ -52,14 +52,10 @@ function wpcf7_akismet( $spam ) {
|
|
52 |
}
|
53 |
|
54 |
function wpcf7_akismet_is_available() {
|
55 |
-
if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) {
|
56 |
return (bool) Akismet::get_api_key();
|
57 |
}
|
58 |
|
59 |
-
if ( function_exists( 'akismet_get_key' ) ) {
|
60 |
-
return (bool) akismet_get_key();
|
61 |
-
}
|
62 |
-
|
63 |
return false;
|
64 |
}
|
65 |
|
@@ -120,16 +116,13 @@ function wpcf7_akismet_submitted_params() {
|
|
120 |
}
|
121 |
|
122 |
function wpcf7_akismet_comment_check( $comment ) {
|
123 |
-
global $akismet_api_host, $akismet_api_port;
|
124 |
-
|
125 |
$spam = false;
|
126 |
$query_string = wpcf7_build_query( $comment );
|
127 |
|
128 |
-
if ( is_callable( array( 'Akismet', 'http_post' ) ) ) {
|
129 |
$response = Akismet::http_post( $query_string, 'comment-check' );
|
130 |
} else {
|
131 |
-
|
132 |
-
'/1.1/comment-check', $akismet_api_port );
|
133 |
}
|
134 |
|
135 |
if ( 'true' == $response[1] ) {
|
52 |
}
|
53 |
|
54 |
function wpcf7_akismet_is_available() {
|
55 |
+
if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) {
|
56 |
return (bool) Akismet::get_api_key();
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
59 |
return false;
|
60 |
}
|
61 |
|
116 |
}
|
117 |
|
118 |
function wpcf7_akismet_comment_check( $comment ) {
|
|
|
|
|
119 |
$spam = false;
|
120 |
$query_string = wpcf7_build_query( $comment );
|
121 |
|
122 |
+
if ( is_callable( array( 'Akismet', 'http_post' ) ) ) {
|
123 |
$response = Akismet::http_post( $query_string, 'comment-check' );
|
124 |
} else {
|
125 |
+
return $spam;
|
|
|
126 |
}
|
127 |
|
128 |
if ( 'true' == $response[1] ) {
|
modules/count.php
CHANGED
@@ -9,7 +9,13 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_count' );
|
|
9 |
|
10 |
function wpcf7_add_form_tag_count() {
|
11 |
wpcf7_add_form_tag( 'count',
|
12 |
-
'wpcf7_count_form_tag_handler',
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
|
15 |
function wpcf7_count_form_tag_handler( $tag ) {
|
9 |
|
10 |
function wpcf7_add_form_tag_count() {
|
11 |
wpcf7_add_form_tag( 'count',
|
12 |
+
'wpcf7_count_form_tag_handler',
|
13 |
+
array(
|
14 |
+
'name-attr' => true,
|
15 |
+
'zero-controls-container' => true,
|
16 |
+
'not-for-mail' => true,
|
17 |
+
)
|
18 |
+
);
|
19 |
}
|
20 |
|
21 |
function wpcf7_count_form_tag_handler( $tag ) {
|
modules/file.php
CHANGED
@@ -32,6 +32,9 @@ function wpcf7_file_form_tag_handler( $tag ) {
|
|
32 |
$atts['id'] = $tag->get_id_option();
|
33 |
$atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
|
34 |
|
|
|
|
|
|
|
35 |
if ( $tag->is_required() ) {
|
36 |
$atts['aria-required'] = 'true';
|
37 |
}
|
@@ -56,7 +59,8 @@ function wpcf7_file_form_tag_handler( $tag ) {
|
|
56 |
add_filter( 'wpcf7_form_enctype', 'wpcf7_file_form_enctype_filter' );
|
57 |
|
58 |
function wpcf7_file_form_enctype_filter( $enctype ) {
|
59 |
-
$multipart = (bool) wpcf7_scan_form_tags(
|
|
|
60 |
|
61 |
if ( $multipart ) {
|
62 |
$enctype = 'multipart/form-data';
|
@@ -91,23 +95,20 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
91 |
return $result;
|
92 |
}
|
93 |
|
94 |
-
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
$file_types = explode( '|', $file_types );
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
}
|
107 |
}
|
108 |
|
109 |
-
|
110 |
-
$file_type_pattern = implode( '|', $allowed_file_types );
|
111 |
|
112 |
$allowed_size = 1048576; // default size 1 MB
|
113 |
|
@@ -133,24 +134,6 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
133 |
}
|
134 |
}
|
135 |
|
136 |
-
/* File type validation */
|
137 |
-
|
138 |
-
// Default file-type restriction
|
139 |
-
if ( '' == $file_type_pattern ) {
|
140 |
-
$file_type_pattern = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
|
141 |
-
}
|
142 |
-
|
143 |
-
$file_type_pattern = trim( $file_type_pattern, '|' );
|
144 |
-
$file_type_pattern = '(' . $file_type_pattern . ')';
|
145 |
-
$file_type_pattern = '/\.' . $file_type_pattern . '$/i';
|
146 |
-
|
147 |
-
if ( ! preg_match( $file_type_pattern, $file['name'] ) ) {
|
148 |
-
$result->invalidate( $tag, wpcf7_get_message( 'upload_file_type_invalid' ) );
|
149 |
-
return $result;
|
150 |
-
}
|
151 |
-
|
152 |
-
/* File size validation */
|
153 |
-
|
154 |
if ( $file['size'] > $allowed_size ) {
|
155 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_file_too_large' ) );
|
156 |
return $result;
|
@@ -162,19 +145,21 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
162 |
|
163 |
$filename = $file['name'];
|
164 |
$filename = wpcf7_canonicalize( $filename, 'as-is' );
|
165 |
-
$filename = sanitize_file_name( $filename );
|
166 |
$filename = wpcf7_antiscript_file_name( $filename );
|
167 |
-
$filename = wp_unique_filename( $uploads_dir, $filename );
|
168 |
|
169 |
-
$
|
|
|
|
|
|
|
|
|
170 |
|
171 |
-
if ( false ===
|
172 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_failed' ) );
|
173 |
return $result;
|
174 |
}
|
175 |
|
176 |
// Make sure the uploaded file is only readable for the owner process
|
177 |
-
|
178 |
|
179 |
if ( $submission = WPCF7_Submission::get_instance() ) {
|
180 |
$submission->add_uploaded_file( $name, $new_file );
|
@@ -315,24 +300,88 @@ function wpcf7_file_display_warning_message() {
|
|
315 |
if ( ! is_dir( $uploads_dir ) || ! wp_is_writable( $uploads_dir ) ) {
|
316 |
$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 );
|
317 |
|
318 |
-
echo '<div class="notice notice-warning"><p
|
|
|
319 |
}
|
320 |
}
|
321 |
|
322 |
|
323 |
/* File uploading functions */
|
324 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
function wpcf7_init_uploads() {
|
326 |
$dir = wpcf7_upload_tmp_dir();
|
327 |
wp_mkdir_p( $dir );
|
328 |
|
329 |
-
$htaccess_file =
|
330 |
|
331 |
if ( file_exists( $htaccess_file ) ) {
|
332 |
return;
|
333 |
}
|
334 |
|
335 |
-
if ( $handle =
|
336 |
fwrite( $handle, "Deny from all\n" );
|
337 |
fclose( $handle );
|
338 |
}
|
@@ -353,10 +402,11 @@ function wpcf7_maybe_add_random_dir( $dir ) {
|
|
353 |
}
|
354 |
|
355 |
function wpcf7_upload_tmp_dir() {
|
356 |
-
if ( defined( 'WPCF7_UPLOADS_TMP_DIR' ) )
|
357 |
return WPCF7_UPLOADS_TMP_DIR;
|
358 |
-
else
|
359 |
-
return wpcf7_upload_dir( 'dir' )
|
|
|
360 |
}
|
361 |
|
362 |
add_action( 'template_redirect', 'wpcf7_cleanup_upload_files', 20 );
|
@@ -377,13 +427,13 @@ function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) {
|
|
377 |
$max = absint( $max );
|
378 |
$count = 0;
|
379 |
|
380 |
-
if ( $handle =
|
381 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
382 |
-
if (
|
383 |
continue;
|
384 |
}
|
385 |
|
386 |
-
$mtime =
|
387 |
|
388 |
if ( $mtime && time() < $mtime + $seconds ) { // less than $seconds old
|
389 |
continue;
|
32 |
$atts['id'] = $tag->get_id_option();
|
33 |
$atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
|
34 |
|
35 |
+
$atts['accept'] = wpcf7_acceptable_filetypes(
|
36 |
+
$tag->get_option( 'filetypes' ), 'attr' );
|
37 |
+
|
38 |
if ( $tag->is_required() ) {
|
39 |
$atts['aria-required'] = 'true';
|
40 |
}
|
59 |
add_filter( 'wpcf7_form_enctype', 'wpcf7_file_form_enctype_filter' );
|
60 |
|
61 |
function wpcf7_file_form_enctype_filter( $enctype ) {
|
62 |
+
$multipart = (bool) wpcf7_scan_form_tags(
|
63 |
+
array( 'type' => array( 'file', 'file*' ) ) );
|
64 |
|
65 |
if ( $multipart ) {
|
66 |
$enctype = 'multipart/form-data';
|
95 |
return $result;
|
96 |
}
|
97 |
|
98 |
+
/* File type validation */
|
99 |
|
100 |
+
$file_type_pattern = wpcf7_acceptable_filetypes(
|
101 |
+
$tag->get_option( 'filetypes' ), 'regex' );
|
|
|
102 |
|
103 |
+
$file_type_pattern = '/\.(' . $file_type_pattern . ')$/i';
|
104 |
+
|
105 |
+
if ( ! preg_match( $file_type_pattern, $file['name'] ) ) {
|
106 |
+
$result->invalidate( $tag,
|
107 |
+
wpcf7_get_message( 'upload_file_type_invalid' ) );
|
108 |
+
return $result;
|
|
|
109 |
}
|
110 |
|
111 |
+
/* File size validation */
|
|
|
112 |
|
113 |
$allowed_size = 1048576; // default size 1 MB
|
114 |
|
134 |
}
|
135 |
}
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
if ( $file['size'] > $allowed_size ) {
|
138 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_file_too_large' ) );
|
139 |
return $result;
|
145 |
|
146 |
$filename = $file['name'];
|
147 |
$filename = wpcf7_canonicalize( $filename, 'as-is' );
|
|
|
148 |
$filename = wpcf7_antiscript_file_name( $filename );
|
|
|
149 |
|
150 |
+
$filename = apply_filters( 'wpcf7_upload_file_name', $filename,
|
151 |
+
$file['name'], $tag );
|
152 |
+
|
153 |
+
$filename = wp_unique_filename( $uploads_dir, $filename );
|
154 |
+
$new_file = path_join( $uploads_dir, $filename );
|
155 |
|
156 |
+
if ( false === move_uploaded_file( $file['tmp_name'], $new_file ) ) {
|
157 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_failed' ) );
|
158 |
return $result;
|
159 |
}
|
160 |
|
161 |
// Make sure the uploaded file is only readable for the owner process
|
162 |
+
chmod( $new_file, 0400 );
|
163 |
|
164 |
if ( $submission = WPCF7_Submission::get_instance() ) {
|
165 |
$submission->add_uploaded_file( $name, $new_file );
|
300 |
if ( ! is_dir( $uploads_dir ) || ! wp_is_writable( $uploads_dir ) ) {
|
301 |
$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 );
|
302 |
|
303 |
+
echo sprintf( '<div class="notice notice-warning"><p>%s</p></div>',
|
304 |
+
esc_html( $message ) );
|
305 |
}
|
306 |
}
|
307 |
|
308 |
|
309 |
/* File uploading functions */
|
310 |
|
311 |
+
function wpcf7_acceptable_filetypes( $types = 'default', $format = 'regex' ) {
|
312 |
+
if ( 'default' === $types || empty( $types ) ) {
|
313 |
+
$types = array(
|
314 |
+
'jpg',
|
315 |
+
'jpeg',
|
316 |
+
'png',
|
317 |
+
'gif',
|
318 |
+
'pdf',
|
319 |
+
'doc',
|
320 |
+
'docx',
|
321 |
+
'ppt',
|
322 |
+
'pptx',
|
323 |
+
'odt',
|
324 |
+
'avi',
|
325 |
+
'ogg',
|
326 |
+
'm4a',
|
327 |
+
'mov',
|
328 |
+
'mp3',
|
329 |
+
'mp4',
|
330 |
+
'mpg',
|
331 |
+
'wav',
|
332 |
+
'wmv',
|
333 |
+
);
|
334 |
+
} else {
|
335 |
+
$types_tmp = (array) $types;
|
336 |
+
$types = array();
|
337 |
+
|
338 |
+
foreach ( $types_tmp as $val ) {
|
339 |
+
if ( is_string( $val ) ) {
|
340 |
+
$val = preg_split( '/[\s|,]+/', $val );
|
341 |
+
}
|
342 |
+
|
343 |
+
$types = array_merge( $types, (array) $val );
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
$types = array_unique( array_filter( $types ) );
|
348 |
+
|
349 |
+
$output = '';
|
350 |
+
|
351 |
+
foreach ( $types as $type ) {
|
352 |
+
$type = trim( $type, ' ,.|' );
|
353 |
+
$type = str_replace(
|
354 |
+
array( '.', '+', '*', '?' ),
|
355 |
+
array( '\.', '\+', '\*', '\?' ),
|
356 |
+
$type );
|
357 |
+
|
358 |
+
if ( '' === $type ) {
|
359 |
+
continue;
|
360 |
+
}
|
361 |
+
|
362 |
+
if ( 'attr' === $format || 'attribute' === $format ) {
|
363 |
+
$output .= sprintf( '.%s', $type );
|
364 |
+
$output .= ',';
|
365 |
+
} else {
|
366 |
+
$output .= $type;
|
367 |
+
$output .= '|';
|
368 |
+
}
|
369 |
+
}
|
370 |
+
|
371 |
+
return trim( $output, ' ,|' );
|
372 |
+
}
|
373 |
+
|
374 |
function wpcf7_init_uploads() {
|
375 |
$dir = wpcf7_upload_tmp_dir();
|
376 |
wp_mkdir_p( $dir );
|
377 |
|
378 |
+
$htaccess_file = path_join( $dir, '.htaccess' );
|
379 |
|
380 |
if ( file_exists( $htaccess_file ) ) {
|
381 |
return;
|
382 |
}
|
383 |
|
384 |
+
if ( $handle = fopen( $htaccess_file, 'w' ) ) {
|
385 |
fwrite( $handle, "Deny from all\n" );
|
386 |
fclose( $handle );
|
387 |
}
|
402 |
}
|
403 |
|
404 |
function wpcf7_upload_tmp_dir() {
|
405 |
+
if ( defined( 'WPCF7_UPLOADS_TMP_DIR' ) ) {
|
406 |
return WPCF7_UPLOADS_TMP_DIR;
|
407 |
+
} else {
|
408 |
+
return path_join( wpcf7_upload_dir( 'dir' ), 'wpcf7_uploads' );
|
409 |
+
}
|
410 |
}
|
411 |
|
412 |
add_action( 'template_redirect', 'wpcf7_cleanup_upload_files', 20 );
|
427 |
$max = absint( $max );
|
428 |
$count = 0;
|
429 |
|
430 |
+
if ( $handle = opendir( $dir ) ) {
|
431 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
432 |
+
if ( '.' == $file || '..' == $file || '.htaccess' == $file ) {
|
433 |
continue;
|
434 |
}
|
435 |
|
436 |
+
$mtime = filemtime( path_join( $dir, $file ) );
|
437 |
|
438 |
if ( $mtime && time() < $mtime + $seconds ) { // less than $seconds old
|
439 |
continue;
|
modules/flamingo.php
CHANGED
@@ -6,14 +6,14 @@
|
|
6 |
|
7 |
add_action( 'wpcf7_submit', 'wpcf7_flamingo_submit', 10, 2 );
|
8 |
|
9 |
-
function wpcf7_flamingo_submit( $
|
10 |
if ( ! class_exists( 'Flamingo_Contact' )
|
11 |
|| ! class_exists( 'Flamingo_Inbound_Message' ) ) {
|
12 |
return;
|
13 |
}
|
14 |
|
15 |
-
if ( $
|
16 |
-
|| $
|
17 |
return;
|
18 |
}
|
19 |
|
@@ -32,7 +32,7 @@ function wpcf7_flamingo_submit( $contactform, $result ) {
|
|
32 |
}
|
33 |
|
34 |
$fields_senseless =
|
35 |
-
$
|
36 |
|
37 |
$exclude_names = array();
|
38 |
|
@@ -48,19 +48,21 @@ function wpcf7_flamingo_submit( $contactform, $result ) {
|
|
48 |
}
|
49 |
}
|
50 |
|
51 |
-
$email = wpcf7_flamingo_get_value( 'email', $
|
52 |
-
$name = wpcf7_flamingo_get_value( 'name', $
|
53 |
-
$subject = wpcf7_flamingo_get_value( 'subject', $
|
54 |
|
55 |
$meta = array();
|
56 |
|
57 |
-
$special_mail_tags = array( '
|
58 |
-
'
|
59 |
-
'post_author', 'post_author_email'
|
|
|
|
|
60 |
|
61 |
foreach ( $special_mail_tags as $smt ) {
|
62 |
-
$meta[$smt] = apply_filters( 'wpcf7_special_mail_tags',
|
63 |
-
|
64 |
}
|
65 |
|
66 |
$akismet = isset( $submission->akismet )
|
@@ -73,10 +75,24 @@ function wpcf7_flamingo_submit( $contactform, $result ) {
|
|
73 |
) );
|
74 |
}
|
75 |
|
76 |
-
$
|
77 |
-
|
|
|
|
|
|
|
|
|
78 |
|
79 |
if ( $channel_id ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
$channel = get_term( $channel_id,
|
81 |
Flamingo_Inbound_Message::channel_taxonomy );
|
82 |
|
@@ -99,6 +115,7 @@ function wpcf7_flamingo_submit( $contactform, $result ) {
|
|
99 |
'meta' => $meta,
|
100 |
'akismet' => $akismet,
|
101 |
'spam' => ( 'spam' == $result['status'] ),
|
|
|
102 |
);
|
103 |
|
104 |
$flamingo_inbound = Flamingo_Inbound_Message::add( $args );
|
@@ -113,15 +130,15 @@ function wpcf7_flamingo_submit( $contactform, $result ) {
|
|
113 |
do_action( 'wpcf7_after_flamingo', $result );
|
114 |
}
|
115 |
|
116 |
-
function wpcf7_flamingo_get_value( $field, $
|
117 |
-
if ( empty( $field ) || empty( $
|
118 |
return false;
|
119 |
}
|
120 |
|
121 |
$value = '';
|
122 |
|
123 |
if ( in_array( $field, array( 'email', 'name', 'subject' ) ) ) {
|
124 |
-
$templates = $
|
125 |
|
126 |
if ( empty( $templates[0] ) ) {
|
127 |
$template = sprintf( '[your-%s]', $field );
|
@@ -133,7 +150,7 @@ function wpcf7_flamingo_get_value( $field, $contactform ) {
|
|
133 |
}
|
134 |
|
135 |
$value = apply_filters( 'wpcf7_flamingo_get_value', $value,
|
136 |
-
$field, $
|
137 |
|
138 |
return $value;
|
139 |
}
|
@@ -184,6 +201,37 @@ function wpcf7_flamingo_add_channel( $slug, $name = '' ) {
|
|
184 |
return (int) $channel['term_id'];
|
185 |
}
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_flamingo_serial_number', 10, 3 );
|
188 |
|
189 |
function wpcf7_flamingo_serial_number( $output, $name, $html ) {
|
@@ -200,8 +248,12 @@ function wpcf7_flamingo_serial_number( $output, $name, $html ) {
|
|
200 |
return $output;
|
201 |
}
|
202 |
|
203 |
-
$
|
204 |
-
|
|
|
|
|
|
|
|
|
205 |
|
206 |
if ( $channel_id ) {
|
207 |
return 1 + (int) Flamingo_Inbound_Message::count(
|
6 |
|
7 |
add_action( 'wpcf7_submit', 'wpcf7_flamingo_submit', 10, 2 );
|
8 |
|
9 |
+
function wpcf7_flamingo_submit( $contact_form, $result ) {
|
10 |
if ( ! class_exists( 'Flamingo_Contact' )
|
11 |
|| ! class_exists( 'Flamingo_Inbound_Message' ) ) {
|
12 |
return;
|
13 |
}
|
14 |
|
15 |
+
if ( $contact_form->in_demo_mode()
|
16 |
+
|| $contact_form->is_true( 'do_not_store' ) ) {
|
17 |
return;
|
18 |
}
|
19 |
|
32 |
}
|
33 |
|
34 |
$fields_senseless =
|
35 |
+
$contact_form->scan_form_tags( array( 'feature' => 'do-not-store' ) );
|
36 |
|
37 |
$exclude_names = array();
|
38 |
|
48 |
}
|
49 |
}
|
50 |
|
51 |
+
$email = wpcf7_flamingo_get_value( 'email', $contact_form );
|
52 |
+
$name = wpcf7_flamingo_get_value( 'name', $contact_form );
|
53 |
+
$subject = wpcf7_flamingo_get_value( 'subject', $contact_form );
|
54 |
|
55 |
$meta = array();
|
56 |
|
57 |
+
$special_mail_tags = array( 'serial_number', 'remote_ip',
|
58 |
+
'user_agent', 'url', 'date', 'time', 'post_id', 'post_name',
|
59 |
+
'post_title', 'post_url', 'post_author', 'post_author_email',
|
60 |
+
'site_title', 'site_description', 'site_url', 'site_admin_email',
|
61 |
+
'user_login', 'user_email', 'user_display_name' );
|
62 |
|
63 |
foreach ( $special_mail_tags as $smt ) {
|
64 |
+
$meta[$smt] = apply_filters( 'wpcf7_special_mail_tags', '',
|
65 |
+
sprintf( '_%s', $smt ), false );
|
66 |
}
|
67 |
|
68 |
$akismet = isset( $submission->akismet )
|
75 |
) );
|
76 |
}
|
77 |
|
78 |
+
$post_meta = get_post_meta( $contact_form->id(), '_flamingo', true );
|
79 |
+
|
80 |
+
$channel_id = isset( $post_meta['channel'] )
|
81 |
+
? (int) $post_meta['channel']
|
82 |
+
: wpcf7_flamingo_add_channel(
|
83 |
+
$contact_form->name(), $contact_form->title() );
|
84 |
|
85 |
if ( $channel_id ) {
|
86 |
+
if ( ! isset( $post_meta['channel'] )
|
87 |
+
|| $post_meta['channel'] !== $channel_id ) {
|
88 |
+
$post_meta = empty( $post_meta ) ? array() : (array) $post_meta;
|
89 |
+
$post_meta = array_merge( $post_meta, array(
|
90 |
+
'channel' => $channel_id,
|
91 |
+
) );
|
92 |
+
|
93 |
+
update_post_meta( $contact_form->id(), '_flamingo', $post_meta );
|
94 |
+
}
|
95 |
+
|
96 |
$channel = get_term( $channel_id,
|
97 |
Flamingo_Inbound_Message::channel_taxonomy );
|
98 |
|
115 |
'meta' => $meta,
|
116 |
'akismet' => $akismet,
|
117 |
'spam' => ( 'spam' == $result['status'] ),
|
118 |
+
'consent' => $submission->collect_consent(),
|
119 |
);
|
120 |
|
121 |
$flamingo_inbound = Flamingo_Inbound_Message::add( $args );
|
130 |
do_action( 'wpcf7_after_flamingo', $result );
|
131 |
}
|
132 |
|
133 |
+
function wpcf7_flamingo_get_value( $field, $contact_form ) {
|
134 |
+
if ( empty( $field ) || empty( $contact_form ) ) {
|
135 |
return false;
|
136 |
}
|
137 |
|
138 |
$value = '';
|
139 |
|
140 |
if ( in_array( $field, array( 'email', 'name', 'subject' ) ) ) {
|
141 |
+
$templates = $contact_form->additional_setting( 'flamingo_' . $field );
|
142 |
|
143 |
if ( empty( $templates[0] ) ) {
|
144 |
$template = sprintf( '[your-%s]', $field );
|
150 |
}
|
151 |
|
152 |
$value = apply_filters( 'wpcf7_flamingo_get_value', $value,
|
153 |
+
$field, $contact_form );
|
154 |
|
155 |
return $value;
|
156 |
}
|
201 |
return (int) $channel['term_id'];
|
202 |
}
|
203 |
|
204 |
+
add_action( 'wpcf7_after_update', 'wpcf7_flamingo_update_channel' );
|
205 |
+
|
206 |
+
function wpcf7_flamingo_update_channel( $contact_form ) {
|
207 |
+
if ( ! class_exists( 'Flamingo_Inbound_Message' ) ) {
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
|
211 |
+
$post_meta = get_post_meta( $contact_form->id(), '_flamingo', true );
|
212 |
+
|
213 |
+
$channel = isset( $post_meta['channel'] )
|
214 |
+
? get_term( $post_meta['channel'],
|
215 |
+
Flamingo_Inbound_Message::channel_taxonomy )
|
216 |
+
: get_term_by( 'slug', $contact_form->name(),
|
217 |
+
Flamingo_Inbound_Message::channel_taxonomy );
|
218 |
+
|
219 |
+
if ( ! $channel || is_wp_error( $channel ) ) {
|
220 |
+
return;
|
221 |
+
}
|
222 |
+
|
223 |
+
if ( $channel->name !== wp_unslash( $contact_form->title() ) ) {
|
224 |
+
wp_update_term( $channel->term_id,
|
225 |
+
Flamingo_Inbound_Message::channel_taxonomy,
|
226 |
+
array(
|
227 |
+
'name' => $contact_form->title(),
|
228 |
+
'slug' => $contact_form->name(),
|
229 |
+
'parent' => $channel->parent,
|
230 |
+
)
|
231 |
+
);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_flamingo_serial_number', 10, 3 );
|
236 |
|
237 |
function wpcf7_flamingo_serial_number( $output, $name, $html ) {
|
248 |
return $output;
|
249 |
}
|
250 |
|
251 |
+
$post_meta = get_post_meta( $contact_form->id(), '_flamingo', true );
|
252 |
+
|
253 |
+
$channel_id = isset( $post_meta['channel'] )
|
254 |
+
? (int) $post_meta['channel']
|
255 |
+
: wpcf7_flamingo_add_channel(
|
256 |
+
$contact_form->name(), $contact_form->title() );
|
257 |
|
258 |
if ( $channel_id ) {
|
259 |
return 1 + (int) Flamingo_Inbound_Message::count(
|
modules/quiz.php
CHANGED
@@ -13,6 +13,7 @@ function wpcf7_add_form_tag_quiz() {
|
|
13 |
array(
|
14 |
'name-attr' => true,
|
15 |
'do-not-store' => true,
|
|
|
16 |
)
|
17 |
);
|
18 |
}
|
13 |
array(
|
14 |
'name-attr' => true,
|
15 |
'do-not-store' => true,
|
16 |
+
'not-for-mail' => true,
|
17 |
)
|
18 |
);
|
19 |
}
|
modules/really-simple-captcha.php
CHANGED
@@ -11,7 +11,11 @@ function wpcf7_add_form_tag_captcha() {
|
|
11 |
// CAPTCHA-Challenge (image)
|
12 |
wpcf7_add_form_tag( 'captchac',
|
13 |
'wpcf7_captchac_form_tag_handler',
|
14 |
-
array(
|
|
|
|
|
|
|
|
|
15 |
);
|
16 |
|
17 |
// CAPTCHA-Response (input)
|
@@ -20,6 +24,7 @@ function wpcf7_add_form_tag_captcha() {
|
|
20 |
array(
|
21 |
'name-attr' => true,
|
22 |
'do-not-store' => true,
|
|
|
23 |
)
|
24 |
);
|
25 |
}
|
@@ -27,6 +32,7 @@ function wpcf7_add_form_tag_captcha() {
|
|
27 |
function wpcf7_captchac_form_tag_handler( $tag ) {
|
28 |
if ( ! class_exists( 'ReallySimpleCaptcha' ) ) {
|
29 |
$error = sprintf(
|
|
|
30 |
esc_html( __( "To use CAPTCHA, you need %s plugin installed.", 'contact-form-7' ) ),
|
31 |
wpcf7_link( 'https://wordpress.org/plugins/really-simple-captcha/', 'Really Simple CAPTCHA' ) );
|
32 |
|
@@ -76,7 +82,7 @@ function wpcf7_captchac_form_tag_handler( $tag ) {
|
|
76 |
|
77 |
$html = sprintf(
|
78 |
'<input type="hidden" name="_wpcf7_captcha_challenge_%1$s" value="%2$s" /><img %3$s />',
|
79 |
-
$tag->name, $prefix, $atts );
|
80 |
|
81 |
return $html;
|
82 |
}
|
@@ -173,23 +179,24 @@ function wpcf7_captcha_ajax_refill( $items ) {
|
|
173 |
return $items;
|
174 |
}
|
175 |
|
176 |
-
$
|
177 |
|
178 |
-
if ( empty( $
|
179 |
return $items;
|
180 |
}
|
181 |
|
182 |
$refill = array();
|
183 |
|
184 |
-
foreach ( $
|
185 |
-
$name = $
|
186 |
-
$options = $
|
187 |
|
188 |
if ( empty( $name ) ) {
|
189 |
continue;
|
190 |
}
|
191 |
|
192 |
$op = wpcf7_captchac_options( $options );
|
|
|
193 |
if ( $filename = wpcf7_generate_captcha( $op ) ) {
|
194 |
$captcha_url = wpcf7_captcha_url( $filename );
|
195 |
$refill[$name] = $captcha_url;
|
@@ -244,7 +251,13 @@ function wpcf7_tag_generator_captcha( $contact_form, $args = '' ) {
|
|
244 |
?>
|
245 |
<div class="control-box">
|
246 |
<fieldset>
|
247 |
-
<legend><?php
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
</fieldset>
|
249 |
</div>
|
250 |
<?php
|
@@ -342,8 +355,9 @@ function wpcf7_captcha_display_warning_message() {
|
|
342 |
echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
|
343 |
}
|
344 |
|
345 |
-
if ( ! function_exists( 'imagecreatetruecolor' )
|
346 |
-
|
|
|
347 |
|
348 |
echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
|
349 |
}
|
@@ -380,13 +394,13 @@ function wpcf7_init_captcha() {
|
|
380 |
}
|
381 |
|
382 |
if ( wp_mkdir_p( $dir ) ) {
|
383 |
-
$htaccess_file = $dir
|
384 |
|
385 |
if ( file_exists( $htaccess_file ) ) {
|
386 |
return $captcha;
|
387 |
}
|
388 |
|
389 |
-
if ( $handle =
|
390 |
fwrite( $handle, 'Order deny,allow' . "\n" );
|
391 |
fwrite( $handle, 'Deny from all' . "\n" );
|
392 |
fwrite( $handle, '<Files ~ "^[0-9A-Za-z]+\\.(jpeg|gif|png)$">' . "\n" );
|
@@ -405,7 +419,7 @@ function wpcf7_captcha_tmp_dir() {
|
|
405 |
if ( defined( 'WPCF7_CAPTCHA_TMP_DIR' ) ) {
|
406 |
return WPCF7_CAPTCHA_TMP_DIR;
|
407 |
} else {
|
408 |
-
return wpcf7_upload_dir( 'dir' )
|
409 |
}
|
410 |
}
|
411 |
|
@@ -413,12 +427,12 @@ function wpcf7_captcha_tmp_url() {
|
|
413 |
if ( defined( 'WPCF7_CAPTCHA_TMP_URL' ) ) {
|
414 |
return WPCF7_CAPTCHA_TMP_URL;
|
415 |
} else {
|
416 |
-
return wpcf7_upload_dir( 'url' )
|
417 |
}
|
418 |
}
|
419 |
|
420 |
function wpcf7_captcha_url( $filename ) {
|
421 |
-
$url =
|
422 |
|
423 |
if ( is_ssl() && 'http:' == substr( $url, 0, 5 ) ) {
|
424 |
$url = 'https:' . substr( $url, 5 );
|
@@ -518,16 +532,16 @@ function wpcf7_cleanup_captcha_files() {
|
|
518 |
return false;
|
519 |
}
|
520 |
|
521 |
-
if ( $handle =
|
522 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
523 |
if ( ! preg_match( '/^[0-9]+\.(php|txt|png|gif|jpeg)$/', $file ) ) {
|
524 |
continue;
|
525 |
}
|
526 |
|
527 |
-
$stat =
|
528 |
|
529 |
if ( $stat['mtime'] + 3600 < time() ) { // 3600 secs == 1 hour
|
530 |
-
|
531 |
}
|
532 |
}
|
533 |
|
@@ -579,12 +593,22 @@ function wpcf7_captchac_options( $options ) {
|
|
579 |
$r = substr( $fc_matches[1], 0, 1 );
|
580 |
$g = substr( $fc_matches[1], 1, 1 );
|
581 |
$b = substr( $fc_matches[1], 2, 1 );
|
582 |
-
|
|
|
|
|
|
|
|
|
|
|
583 |
} elseif ( 6 == strlen( $fc_matches[1] ) ) {
|
584 |
$r = substr( $fc_matches[1], 0, 2 );
|
585 |
$g = substr( $fc_matches[1], 2, 2 );
|
586 |
$b = substr( $fc_matches[1], 4, 2 );
|
587 |
-
|
|
|
|
|
|
|
|
|
|
|
588 |
}
|
589 |
}
|
590 |
|
@@ -599,12 +623,22 @@ function wpcf7_captchac_options( $options ) {
|
|
599 |
$r = substr( $bc_matches[1], 0, 1 );
|
600 |
$g = substr( $bc_matches[1], 1, 1 );
|
601 |
$b = substr( $bc_matches[1], 2, 1 );
|
602 |
-
|
|
|
|
|
|
|
|
|
|
|
603 |
} elseif ( 6 == strlen( $bc_matches[1] ) ) {
|
604 |
$r = substr( $bc_matches[1], 0, 2 );
|
605 |
$g = substr( $bc_matches[1], 2, 2 );
|
606 |
$b = substr( $bc_matches[1], 4, 2 );
|
607 |
-
|
|
|
|
|
|
|
|
|
|
|
608 |
}
|
609 |
}
|
610 |
|
11 |
// CAPTCHA-Challenge (image)
|
12 |
wpcf7_add_form_tag( 'captchac',
|
13 |
'wpcf7_captchac_form_tag_handler',
|
14 |
+
array(
|
15 |
+
'name-attr' => true,
|
16 |
+
'zero-controls-container' => true,
|
17 |
+
'not-for-mail' => true,
|
18 |
+
)
|
19 |
);
|
20 |
|
21 |
// CAPTCHA-Response (input)
|
24 |
array(
|
25 |
'name-attr' => true,
|
26 |
'do-not-store' => true,
|
27 |
+
'not-for-mail' => true,
|
28 |
)
|
29 |
);
|
30 |
}
|
32 |
function wpcf7_captchac_form_tag_handler( $tag ) {
|
33 |
if ( ! class_exists( 'ReallySimpleCaptcha' ) ) {
|
34 |
$error = sprintf(
|
35 |
+
/* translators: %s: link labeled 'Really Simple CAPTCHA' */
|
36 |
esc_html( __( "To use CAPTCHA, you need %s plugin installed.", 'contact-form-7' ) ),
|
37 |
wpcf7_link( 'https://wordpress.org/plugins/really-simple-captcha/', 'Really Simple CAPTCHA' ) );
|
38 |
|
82 |
|
83 |
$html = sprintf(
|
84 |
'<input type="hidden" name="_wpcf7_captcha_challenge_%1$s" value="%2$s" /><img %3$s />',
|
85 |
+
$tag->name, esc_attr( $prefix ), $atts );
|
86 |
|
87 |
return $html;
|
88 |
}
|
179 |
return $items;
|
180 |
}
|
181 |
|
182 |
+
$tags = wpcf7_scan_form_tags( array( 'type' => 'captchac' ) );
|
183 |
|
184 |
+
if ( empty( $tags ) ) {
|
185 |
return $items;
|
186 |
}
|
187 |
|
188 |
$refill = array();
|
189 |
|
190 |
+
foreach ( $tags as $tag ) {
|
191 |
+
$name = $tag->name;
|
192 |
+
$options = $tag->options;
|
193 |
|
194 |
if ( empty( $name ) ) {
|
195 |
continue;
|
196 |
}
|
197 |
|
198 |
$op = wpcf7_captchac_options( $options );
|
199 |
+
|
200 |
if ( $filename = wpcf7_generate_captcha( $op ) ) {
|
201 |
$captcha_url = wpcf7_captcha_url( $filename );
|
202 |
$refill[$name] = $captcha_url;
|
251 |
?>
|
252 |
<div class="control-box">
|
253 |
<fieldset>
|
254 |
+
<legend><?php
|
255 |
+
echo sprintf(
|
256 |
+
/* translators: %s: link labeled 'Really Simple CAPTCHA' */
|
257 |
+
esc_html( __( "To use CAPTCHA, you first need to install and activate %s plugin.", 'contact-form-7' ) ),
|
258 |
+
wpcf7_link( 'https://wordpress.org/plugins/really-simple-captcha/', 'Really Simple CAPTCHA' )
|
259 |
+
);
|
260 |
+
?></legend>
|
261 |
</fieldset>
|
262 |
</div>
|
263 |
<?php
|
355 |
echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
|
356 |
}
|
357 |
|
358 |
+
if ( ! function_exists( 'imagecreatetruecolor' )
|
359 |
+
|| ! function_exists( 'imagettftext' ) ) {
|
360 |
+
$message = __( "This contact form contains CAPTCHA fields, but the necessary libraries (GD and FreeType) are not available on your server.", 'contact-form-7' );
|
361 |
|
362 |
echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
|
363 |
}
|
394 |
}
|
395 |
|
396 |
if ( wp_mkdir_p( $dir ) ) {
|
397 |
+
$htaccess_file = path_join( $dir, '.htaccess' );
|
398 |
|
399 |
if ( file_exists( $htaccess_file ) ) {
|
400 |
return $captcha;
|
401 |
}
|
402 |
|
403 |
+
if ( $handle = fopen( $htaccess_file, 'w' ) ) {
|
404 |
fwrite( $handle, 'Order deny,allow' . "\n" );
|
405 |
fwrite( $handle, 'Deny from all' . "\n" );
|
406 |
fwrite( $handle, '<Files ~ "^[0-9A-Za-z]+\\.(jpeg|gif|png)$">' . "\n" );
|
419 |
if ( defined( 'WPCF7_CAPTCHA_TMP_DIR' ) ) {
|
420 |
return WPCF7_CAPTCHA_TMP_DIR;
|
421 |
} else {
|
422 |
+
return path_join( wpcf7_upload_dir( 'dir' ), 'wpcf7_captcha' );
|
423 |
}
|
424 |
}
|
425 |
|
427 |
if ( defined( 'WPCF7_CAPTCHA_TMP_URL' ) ) {
|
428 |
return WPCF7_CAPTCHA_TMP_URL;
|
429 |
} else {
|
430 |
+
return path_join( wpcf7_upload_dir( 'url' ), 'wpcf7_captcha' );
|
431 |
}
|
432 |
}
|
433 |
|
434 |
function wpcf7_captcha_url( $filename ) {
|
435 |
+
$url = path_join( wpcf7_captcha_tmp_url(), $filename );
|
436 |
|
437 |
if ( is_ssl() && 'http:' == substr( $url, 0, 5 ) ) {
|
438 |
$url = 'https:' . substr( $url, 5 );
|
532 |
return false;
|
533 |
}
|
534 |
|
535 |
+
if ( $handle = opendir( $dir ) ) {
|
536 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
537 |
if ( ! preg_match( '/^[0-9]+\.(php|txt|png|gif|jpeg)$/', $file ) ) {
|
538 |
continue;
|
539 |
}
|
540 |
|
541 |
+
$stat = stat( path_join( $dir, $file ) );
|
542 |
|
543 |
if ( $stat['mtime'] + 3600 < time() ) { // 3600 secs == 1 hour
|
544 |
+
unlink( path_join( $dir, $file ) );
|
545 |
}
|
546 |
}
|
547 |
|
593 |
$r = substr( $fc_matches[1], 0, 1 );
|
594 |
$g = substr( $fc_matches[1], 1, 1 );
|
595 |
$b = substr( $fc_matches[1], 2, 1 );
|
596 |
+
|
597 |
+
$op['fg'] = array(
|
598 |
+
hexdec( $r . $r ),
|
599 |
+
hexdec( $g . $g ),
|
600 |
+
hexdec( $b . $b ),
|
601 |
+
);
|
602 |
} elseif ( 6 == strlen( $fc_matches[1] ) ) {
|
603 |
$r = substr( $fc_matches[1], 0, 2 );
|
604 |
$g = substr( $fc_matches[1], 2, 2 );
|
605 |
$b = substr( $fc_matches[1], 4, 2 );
|
606 |
+
|
607 |
+
$op['fg'] = array(
|
608 |
+
hexdec( $r ),
|
609 |
+
hexdec( $g ),
|
610 |
+
hexdec( $b ),
|
611 |
+
);
|
612 |
}
|
613 |
}
|
614 |
|
623 |
$r = substr( $bc_matches[1], 0, 1 );
|
624 |
$g = substr( $bc_matches[1], 1, 1 );
|
625 |
$b = substr( $bc_matches[1], 2, 1 );
|
626 |
+
|
627 |
+
$op['bg'] = array(
|
628 |
+
hexdec( $r . $r ),
|
629 |
+
hexdec( $g . $g ),
|
630 |
+
hexdec( $b . $b ),
|
631 |
+
);
|
632 |
} elseif ( 6 == strlen( $bc_matches[1] ) ) {
|
633 |
$r = substr( $bc_matches[1], 0, 2 );
|
634 |
$g = substr( $bc_matches[1], 2, 2 );
|
635 |
$b = substr( $bc_matches[1], 4, 2 );
|
636 |
+
|
637 |
+
$op['bg'] = array(
|
638 |
+
hexdec( $r ),
|
639 |
+
hexdec( $g ),
|
640 |
+
hexdec( $b ),
|
641 |
+
);
|
642 |
}
|
643 |
}
|
644 |
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: takayukister
|
3 |
Donate link: https://contactform7.com/donate/
|
4 |
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
|
5 |
-
Requires at least: 4.
|
6 |
-
Tested up to: 4.9.
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -60,48 +60,18 @@ Do you have questions or issues with Contact Form 7? Use these support channels
|
|
60 |
|
61 |
For more information, see [Releases](https://contactform7.com/category/releases/).
|
62 |
|
63 |
-
=
|
64 |
-
|
65 |
-
*
|
66 |
-
*
|
67 |
-
*
|
68 |
-
*
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
*
|
73 |
-
*
|
74 |
-
*
|
75 |
-
*
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
* Supports subscribers_only setting
|
80 |
-
* Changes the default value of WPCF7_VERIFY_NONCE to false
|
81 |
-
* WPCF7_FormTagsManager::collect_tag_types() supports invert option
|
82 |
-
* New filter hooks: wpcf7_verify_nonce, wpcf7_subscribers_only_notice, wpcf7_remote_ip_addr, and wpcf7_submission_is_blacklisted
|
83 |
-
* Fixed: Form-tag's tabindex option did not accept 0 or negative integer values
|
84 |
-
* Shows a validation error when no option in a radio buttons group is checked
|
85 |
-
* Config validator: Adds a validation rule against the use of deprecated settings (on_sent_ok and on_submit)
|
86 |
-
* Allows to pass the skip_mail option through the WPCF7_ContactForm::submit() and WPCF7_Submission::get_instance() function parameters.
|
87 |
-
* Triggers wpcf7beforesubmit custom DOM event. You can manipulate the formData object through an event handler.
|
88 |
-
|
89 |
-
= 4.8.1 =
|
90 |
-
|
91 |
-
* wpcf7.initForm JavaScript function added to isolate form initialization process.
|
92 |
-
* Fix response message duplication caused by repeated click on submit button.
|
93 |
-
* Clear $phpmailer->AltBody to avoid unintended inheritance from previous wp_mail() calls.
|
94 |
-
* Fix incorrect character count of textarea input.
|
95 |
-
* Akismet: Exclude the comment_author, comment_author_email, and comment_author_url values from the comment_content value.
|
96 |
-
* REST API: More reliable approach to build route URLs.
|
97 |
-
* Include free_text inputs into event.detail.inputs.
|
98 |
-
|
99 |
-
= 4.8 =
|
100 |
-
|
101 |
-
* Stopped using jquery.form.js.
|
102 |
-
* Added custom REST API endpoints for Ajax form submissions.
|
103 |
-
* WPCF7_FormTag class implements ArrayAccess interface.
|
104 |
-
* WPCF7_FormTagsManager::filter() filters form-tags based on features they support.
|
105 |
-
* New form-tag features: do-not-store, display-block, and display-hidden
|
106 |
-
* Removed inappropriate content from h1 headings.
|
107 |
-
* Added the support of size:invisible option to the reCAPTCHA form-tag.
|
2 |
Contributors: takayukister
|
3 |
Donate link: https://contactform7.com/donate/
|
4 |
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
|
5 |
+
Requires at least: 4.8
|
6 |
+
Tested up to: 4.9.2
|
7 |
+
Stable tag: 5.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
60 |
|
61 |
For more information, see [Releases](https://contactform7.com/category/releases/).
|
62 |
|
63 |
+
= 5.0 =
|
64 |
+
|
65 |
+
* Additional settings: on_sent_ok and on_submit have been removed.
|
66 |
+
* New additional setting: skip_mail
|
67 |
+
* Flamingo: Inbound channel title changes in conjunction with a change in the title of the corresponding contact form.
|
68 |
+
* DOM events: Make an entire API response object accessible through the event.detail.apiResponse property.
|
69 |
+
* HTML mail: Adds language-related attributes to the HTML header.
|
70 |
+
* File upload: Sets the accept attribute to an uploading field.
|
71 |
+
* Introduces the WPCF7_MailTag class.
|
72 |
+
* Allows aborting a mail-sending attempt using the wpcf7_before_send_mail action hook. Also, you can set a custom status and a message through the action hook.
|
73 |
+
* Acceptance checkbox: Allows the specifying of a statement of conditions in the form-tag’s content part.
|
74 |
+
* Acceptance checkbox: Supports the optional option.
|
75 |
+
* New special mail tags: [_site_title], [_site_description], [_site_url], [_site_admin_email], [_invalid_fields], [_user_login], [_user_email], [_user_url], [_user_first_name], [_user_last_name], [_user_nickname], and [_user_display_name]
|
76 |
+
* New filter hooks: wpcf7_upload_file_name, wpcf7_autop_or_not, wpcf7_posted_data_{$type}, and wpcf7_mail_tag_replaced_{$type}
|
77 |
+
* New form-tag features: zero-controls-container and not-for-mail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings.php
CHANGED
@@ -12,6 +12,7 @@ require_once WPCF7_PLUGIN_DIR . '/includes/contact-form-template.php';
|
|
12 |
require_once WPCF7_PLUGIN_DIR . '/includes/contact-form.php';
|
13 |
require_once WPCF7_PLUGIN_DIR . '/includes/contact-form-functions.php';
|
14 |
require_once WPCF7_PLUGIN_DIR . '/includes/mail.php';
|
|
|
15 |
require_once WPCF7_PLUGIN_DIR . '/includes/submission.php';
|
16 |
require_once WPCF7_PLUGIN_DIR . '/includes/upgrade.php';
|
17 |
require_once WPCF7_PLUGIN_DIR . '/includes/integration.php';
|
12 |
require_once WPCF7_PLUGIN_DIR . '/includes/contact-form.php';
|
13 |
require_once WPCF7_PLUGIN_DIR . '/includes/contact-form-functions.php';
|
14 |
require_once WPCF7_PLUGIN_DIR . '/includes/mail.php';
|
15 |
+
require_once WPCF7_PLUGIN_DIR . '/includes/special-mail-tags.php';
|
16 |
require_once WPCF7_PLUGIN_DIR . '/includes/submission.php';
|
17 |
require_once WPCF7_PLUGIN_DIR . '/includes/upgrade.php';
|
18 |
require_once WPCF7_PLUGIN_DIR . '/includes/integration.php';
|
wp-contact-form-7.php
CHANGED
@@ -7,12 +7,12 @@ Author: Takayuki Miyoshi
|
|
7 |
Author URI: https://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
-
Version:
|
11 |
*/
|
12 |
|
13 |
-
define( 'WPCF7_VERSION', '
|
14 |
|
15 |
-
define( 'WPCF7_REQUIRED_WP_VERSION', '4.
|
16 |
|
17 |
define( 'WPCF7_PLUGIN', __FILE__ );
|
18 |
|
7 |
Author URI: https://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
+
Version: 5.0
|
11 |
*/
|
12 |
|
13 |
+
define( 'WPCF7_VERSION', '5.0' );
|
14 |
|
15 |
+
define( 'WPCF7_REQUIRED_WP_VERSION', '4.8' );
|
16 |
|
17 |
define( 'WPCF7_PLUGIN', __FILE__ );
|
18 |
|