Version Description
- Added REST API custom endpoints to manipulate contact form data.
- Config Validator: Added test items for field names and attachment file paths.
- Added custom DOM events:
wpcf7invalid
,wpcf7spam
,wpcf7mailsent
,wpcf7mailfailed
andwpcf7submit
. - New action hook:
wpcf7_after_flamingo
. - Added
size
option toselect
andselect*
form-tag types. - Made it possible to use the 3rd parameter of
wpcf7_add_form_tag()
to specify "features" of the form-tag type.
Download this release
Release Info
Developer | takayukister |
Plugin | Contact Form 7 |
Version | 4.7 |
Comparing to | |
See all releases |
Code changes from version 4.6.1 to 4.7
- admin/admin.php +97 -66
- admin/css/styles-rtl.css +4 -5
- admin/css/styles.css +24 -24
- admin/edit-contact-form.php +4 -4
- admin/includes/admin-functions.php +0 -144
- admin/includes/class-contact-forms-list-table.php +41 -23
- admin/includes/editor.php +40 -20
- admin/includes/help-tabs.php +3 -3
- admin/includes/tag-generator.php +4 -2
- admin/includes/welcome-panel.php +2 -2
- admin/js/scripts.js +211 -94
- admin/js/tag-generator.js +128 -122
- includes/capabilities.php +2 -1
- includes/config-validator.php +330 -167
- includes/contact-form-functions.php +267 -0
- includes/contact-form-template.php +14 -12
- includes/contact-form.php +78 -197
- includes/controller.php +17 -7
- includes/css/styles.css +1 -0
- includes/form-tag.php +2 -1
- includes/form-tags-manager.php +88 -14
- includes/formatting.php +18 -6
- includes/functions.php +12 -6
- includes/integration.php +2 -1
- includes/js/scripts.js +315 -266
- includes/l10n.php +4 -2
- includes/mail.php +17 -8
- includes/rest-api.php +248 -0
- includes/submission.php +5 -4
- includes/upgrade.php +4 -2
- includes/validation.php +4 -2
- modules/acceptance.php +2 -2
- modules/checkbox.php +5 -2
- modules/count.php +2 -1
- modules/date.php +2 -2
- modules/file.php +2 -2
- modules/flamingo.php +10 -2
- modules/hidden.php +2 -1
- modules/listo.php +1 -1
- modules/number.php +2 -2
- modules/quiz.php +3 -2
- modules/really-simple-captcha.php +2 -2
- modules/recaptcha.php +7 -3
- modules/select.php +19 -4
- modules/submit.php +1 -1
- modules/text.php +2 -2
- modules/textarea.php +2 -2
- readme.txt +22 -13
- settings.php +16 -8
- uninstall.php +7 -4
- wp-contact-form-7.php +4 -4
admin/admin.php
CHANGED
@@ -59,8 +59,9 @@ function wpcf7_set_screen_options( $result, $option, $value ) {
|
|
59 |
$wpcf7_screens = array(
|
60 |
'cfseven_contact_forms_per_page' );
|
61 |
|
62 |
-
if ( in_array( $option, $wpcf7_screens ) )
|
63 |
$result = $value;
|
|
|
64 |
|
65 |
return $result;
|
66 |
}
|
@@ -71,18 +72,60 @@ function wpcf7_load_contact_form_admin() {
|
|
71 |
$action = wpcf7_current_action();
|
72 |
|
73 |
if ( 'save' == $action ) {
|
74 |
-
$id = $_POST['post_ID'];
|
75 |
check_admin_referer( 'wpcf7-save-contact-form_' . $id );
|
76 |
|
77 |
-
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) )
|
78 |
wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
$
|
|
|
|
|
|
|
|
|
81 |
|
82 |
$query = array(
|
83 |
-
'
|
84 |
-
'
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
|
88 |
wp_safe_redirect( $redirect_to );
|
@@ -96,8 +139,9 @@ function wpcf7_load_contact_form_admin() {
|
|
96 |
|
97 |
check_admin_referer( 'wpcf7-copy-contact-form_' . $id );
|
98 |
|
99 |
-
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) )
|
100 |
wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
|
|
|
101 |
|
102 |
$query = array();
|
103 |
|
@@ -116,12 +160,13 @@ function wpcf7_load_contact_form_admin() {
|
|
116 |
}
|
117 |
|
118 |
if ( 'delete' == $action ) {
|
119 |
-
if ( ! empty( $_POST['post_ID'] ) )
|
120 |
check_admin_referer( 'wpcf7-delete-contact-form_' . $_POST['post_ID'] );
|
121 |
-
elseif ( ! is_array( $_REQUEST['post'] ) )
|
122 |
check_admin_referer( 'wpcf7-delete-contact-form_' . $_REQUEST['post'] );
|
123 |
-
else
|
124 |
check_admin_referer( 'bulk-posts' );
|
|
|
125 |
|
126 |
$posts = empty( $_POST['post_ID'] )
|
127 |
? (array) $_REQUEST['post']
|
@@ -132,22 +177,26 @@ function wpcf7_load_contact_form_admin() {
|
|
132 |
foreach ( $posts as $post ) {
|
133 |
$post = WPCF7_ContactForm::get_instance( $post );
|
134 |
|
135 |
-
if ( empty( $post ) )
|
136 |
continue;
|
|
|
137 |
|
138 |
-
if ( ! current_user_can( 'wpcf7_delete_contact_form', $post->id() ) )
|
139 |
wp_die( __( 'You are not allowed to delete this item.', 'contact-form-7' ) );
|
|
|
140 |
|
141 |
-
if ( ! $post->delete() )
|
142 |
wp_die( __( 'Error in deleting.', 'contact-form-7' ) );
|
|
|
143 |
|
144 |
$deleted += 1;
|
145 |
}
|
146 |
|
147 |
$query = array();
|
148 |
|
149 |
-
if ( ! empty( $deleted ) )
|
150 |
$query['message'] = 'deleted';
|
|
|
151 |
|
152 |
$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
|
153 |
|
@@ -164,15 +213,18 @@ function wpcf7_load_contact_form_admin() {
|
|
164 |
}
|
165 |
|
166 |
$contact_forms = WPCF7_ContactForm::find();
|
|
|
167 |
$result = array(
|
168 |
'timestamp' => current_time( 'timestamp' ),
|
169 |
'version' => WPCF7_VERSION,
|
170 |
'count_valid' => 0,
|
171 |
-
'count_invalid' => 0
|
|
|
172 |
|
173 |
foreach ( $contact_forms as $contact_form ) {
|
174 |
$config_validator = new WPCF7_ConfigValidator( $contact_form );
|
175 |
$config_validator->validate();
|
|
|
176 |
|
177 |
if ( $config_validator->is_valid() ) {
|
178 |
$result['count_valid'] += 1;
|
@@ -248,30 +300,34 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
|
|
248 |
WPCF7_VERSION, true );
|
249 |
|
250 |
$args = array(
|
|
|
|
|
|
|
|
|
251 |
'pluginUrl' => wpcf7_plugin_url(),
|
252 |
'saveAlert' => __(
|
253 |
"The changes you made will be lost if you navigate away from this page.",
|
254 |
'contact-form-7' ),
|
255 |
'activeTab' => isset( $_GET['active-tab'] )
|
256 |
? (int) $_GET['active-tab'] : 0,
|
257 |
-
'
|
258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
|
260 |
if ( ( $post = wpcf7_get_current_contact_form() )
|
261 |
&& current_user_can( 'wpcf7_edit_contact_form', $post->id() )
|
262 |
&& wpcf7_validate_configuration() ) {
|
263 |
$config_validator = new WPCF7_ConfigValidator( $post );
|
264 |
-
$
|
265 |
-
|
266 |
-
|
267 |
-
$args['configErrors'][$section] = array();
|
268 |
-
|
269 |
-
foreach ( $errors as $error ) {
|
270 |
-
$args['configErrors'][$section][] = array(
|
271 |
-
'message' => esc_html( $error['message'] ),
|
272 |
-
'link' => esc_url( $error['link'] ) );
|
273 |
-
}
|
274 |
-
}
|
275 |
}
|
276 |
|
277 |
wp_localize_script( 'wpcf7-admin', '_wpcf7', $args );
|
@@ -355,7 +411,7 @@ function wpcf7_admin_bulk_validate_page() {
|
|
355 |
<p><input type="submit" class="button" value="<?php echo esc_attr( $submit_text ); ?>" /></p>
|
356 |
</form>
|
357 |
|
358 |
-
<?php echo wpcf7_link( __( '
|
359 |
|
360 |
</div>
|
361 |
<?php
|
@@ -431,7 +487,15 @@ function wpcf7_admin_updated_message() {
|
|
431 |
}
|
432 |
|
433 |
if ( ! empty( $updated_message ) ) {
|
434 |
-
echo sprintf( '<div id="message" class="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
return;
|
436 |
}
|
437 |
|
@@ -462,8 +526,9 @@ function wpcf7_admin_updated_message() {
|
|
462 |
add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 );
|
463 |
|
464 |
function wpcf7_plugin_action_links( $links, $file ) {
|
465 |
-
if ( $file != WPCF7_PLUGIN_BASENAME )
|
466 |
return $links;
|
|
|
467 |
|
468 |
$settings_link = '<a href="' . menu_page_url( 'wpcf7', false ) . '">'
|
469 |
. esc_html( __( 'Settings', 'contact-form-7' ) ) . '</a>';
|
@@ -510,40 +575,6 @@ function wpcf7_not_allowed_to_edit() {
|
|
510 |
esc_html( $message ) );
|
511 |
}
|
512 |
|
513 |
-
add_action( 'wpcf7_admin_misc_pub_section', 'wpcf7_notice_config_errors' );
|
514 |
-
|
515 |
-
function wpcf7_notice_config_errors() {
|
516 |
-
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
517 |
-
return;
|
518 |
-
}
|
519 |
-
|
520 |
-
if ( ! wpcf7_validate_configuration()
|
521 |
-
|| ! current_user_can( 'wpcf7_edit_contact_form', $contact_form->id() ) ) {
|
522 |
-
return;
|
523 |
-
}
|
524 |
-
|
525 |
-
$config_validator = new WPCF7_ConfigValidator( $contact_form );
|
526 |
-
|
527 |
-
if ( $count_errors = $config_validator->count_errors() ) {
|
528 |
-
$message = sprintf(
|
529 |
-
_n(
|
530 |
-
'%s configuration error found',
|
531 |
-
'%s configuration errors found',
|
532 |
-
$count_errors, 'contact-form-7' ),
|
533 |
-
number_format_i18n( $count_errors ) );
|
534 |
-
|
535 |
-
$link = wpcf7_link(
|
536 |
-
__( 'http://contactform7.com/configuration-validator-faq/',
|
537 |
-
'contact-form-7' ),
|
538 |
-
__( "What's this?", 'contact-form-7' ),
|
539 |
-
array( 'class' => 'external' ) );
|
540 |
-
|
541 |
-
echo sprintf(
|
542 |
-
'<div class="misc-pub-section warning">%1$s<br />%2$s</div>',
|
543 |
-
$message, $link );
|
544 |
-
}
|
545 |
-
}
|
546 |
-
|
547 |
add_action( 'wpcf7_admin_warnings', 'wpcf7_notice_bulk_validate_config', 5 );
|
548 |
|
549 |
function wpcf7_notice_bulk_validate_config() {
|
59 |
$wpcf7_screens = array(
|
60 |
'cfseven_contact_forms_per_page' );
|
61 |
|
62 |
+
if ( in_array( $option, $wpcf7_screens ) ) {
|
63 |
$result = $value;
|
64 |
+
}
|
65 |
|
66 |
return $result;
|
67 |
}
|
72 |
$action = wpcf7_current_action();
|
73 |
|
74 |
if ( 'save' == $action ) {
|
75 |
+
$id = isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : '-1';
|
76 |
check_admin_referer( 'wpcf7-save-contact-form_' . $id );
|
77 |
|
78 |
+
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
|
79 |
wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
|
80 |
+
}
|
81 |
+
|
82 |
+
$args = $_REQUEST;
|
83 |
+
$args['id'] = $id;
|
84 |
+
|
85 |
+
$args['title'] = isset( $_POST['post_title'] )
|
86 |
+
? $_POST['post_title'] : null;
|
87 |
+
|
88 |
+
$args['locale'] = isset( $_POST['wpcf7-locale'] )
|
89 |
+
? $_POST['wpcf7-locale'] : null;
|
90 |
+
|
91 |
+
$args['form'] = isset( $_POST['wpcf7-form'] )
|
92 |
+
? $_POST['wpcf7-form'] : '';
|
93 |
+
|
94 |
+
$args['mail'] = isset( $_POST['wpcf7-mail'] )
|
95 |
+
? wpcf7_sanitize_mail( $_POST['wpcf7-mail'] )
|
96 |
+
: array();
|
97 |
+
|
98 |
+
$args['mail_2'] = isset( $_POST['wpcf7-mail-2'] )
|
99 |
+
? wpcf7_sanitize_mail( $_POST['wpcf7-mail-2'] )
|
100 |
+
: array();
|
101 |
+
|
102 |
+
$args['messages'] = isset( $_POST['wpcf7-messages'] )
|
103 |
+
? $_POST['wpcf7-messages'] : array();
|
104 |
+
|
105 |
+
$args['additional_settings'] = isset( $_POST['wpcf7-additional-settings'] )
|
106 |
+
? $_POST['wpcf7-additional-settings'] : '';
|
107 |
+
|
108 |
+
$contact_form = wpcf7_save_contact_form( $args );
|
109 |
|
110 |
+
if ( $contact_form && wpcf7_validate_configuration() ) {
|
111 |
+
$config_validator = new WPCF7_ConfigValidator( $contact_form );
|
112 |
+
$config_validator->validate();
|
113 |
+
$config_validator->save();
|
114 |
+
}
|
115 |
|
116 |
$query = array(
|
117 |
+
'post' => $contact_form ? $contact_form->id() : 0,
|
118 |
+
'active-tab' => isset( $_POST['active-tab'] )
|
119 |
+
? (int) $_POST['active-tab'] : 0,
|
120 |
+
);
|
121 |
+
|
122 |
+
if ( ! $contact_form ) {
|
123 |
+
$query['message'] = 'failed';
|
124 |
+
} elseif ( -1 == $id ) {
|
125 |
+
$query['message'] = 'created';
|
126 |
+
} else {
|
127 |
+
$query['message'] = 'saved';
|
128 |
+
}
|
129 |
|
130 |
$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
|
131 |
wp_safe_redirect( $redirect_to );
|
139 |
|
140 |
check_admin_referer( 'wpcf7-copy-contact-form_' . $id );
|
141 |
|
142 |
+
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
|
143 |
wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
|
144 |
+
}
|
145 |
|
146 |
$query = array();
|
147 |
|
160 |
}
|
161 |
|
162 |
if ( 'delete' == $action ) {
|
163 |
+
if ( ! empty( $_POST['post_ID'] ) ) {
|
164 |
check_admin_referer( 'wpcf7-delete-contact-form_' . $_POST['post_ID'] );
|
165 |
+
} elseif ( ! is_array( $_REQUEST['post'] ) ) {
|
166 |
check_admin_referer( 'wpcf7-delete-contact-form_' . $_REQUEST['post'] );
|
167 |
+
} else {
|
168 |
check_admin_referer( 'bulk-posts' );
|
169 |
+
}
|
170 |
|
171 |
$posts = empty( $_POST['post_ID'] )
|
172 |
? (array) $_REQUEST['post']
|
177 |
foreach ( $posts as $post ) {
|
178 |
$post = WPCF7_ContactForm::get_instance( $post );
|
179 |
|
180 |
+
if ( empty( $post ) ) {
|
181 |
continue;
|
182 |
+
}
|
183 |
|
184 |
+
if ( ! current_user_can( 'wpcf7_delete_contact_form', $post->id() ) ) {
|
185 |
wp_die( __( 'You are not allowed to delete this item.', 'contact-form-7' ) );
|
186 |
+
}
|
187 |
|
188 |
+
if ( ! $post->delete() ) {
|
189 |
wp_die( __( 'Error in deleting.', 'contact-form-7' ) );
|
190 |
+
}
|
191 |
|
192 |
$deleted += 1;
|
193 |
}
|
194 |
|
195 |
$query = array();
|
196 |
|
197 |
+
if ( ! empty( $deleted ) ) {
|
198 |
$query['message'] = 'deleted';
|
199 |
+
}
|
200 |
|
201 |
$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
|
202 |
|
213 |
}
|
214 |
|
215 |
$contact_forms = WPCF7_ContactForm::find();
|
216 |
+
|
217 |
$result = array(
|
218 |
'timestamp' => current_time( 'timestamp' ),
|
219 |
'version' => WPCF7_VERSION,
|
220 |
'count_valid' => 0,
|
221 |
+
'count_invalid' => 0,
|
222 |
+
);
|
223 |
|
224 |
foreach ( $contact_forms as $contact_form ) {
|
225 |
$config_validator = new WPCF7_ConfigValidator( $contact_form );
|
226 |
$config_validator->validate();
|
227 |
+
$config_validator->save();
|
228 |
|
229 |
if ( $config_validator->is_valid() ) {
|
230 |
$result['count_valid'] += 1;
|
300 |
WPCF7_VERSION, true );
|
301 |
|
302 |
$args = array(
|
303 |
+
'apiSettings' => array(
|
304 |
+
'root' => esc_url_raw( get_rest_url() ),
|
305 |
+
'nonce' => ( wp_installing() && ! is_multisite() )
|
306 |
+
? '' : wp_create_nonce( 'wp_rest' ) ),
|
307 |
'pluginUrl' => wpcf7_plugin_url(),
|
308 |
'saveAlert' => __(
|
309 |
"The changes you made will be lost if you navigate away from this page.",
|
310 |
'contact-form-7' ),
|
311 |
'activeTab' => isset( $_GET['active-tab'] )
|
312 |
? (int) $_GET['active-tab'] : 0,
|
313 |
+
'configValidator' => array(
|
314 |
+
'errors' => array(),
|
315 |
+
'howToCorrect' => __( "How to correct this?", 'contact-form-7' ),
|
316 |
+
'oneError' => __( '1 configuration error detected', 'contact-form-7' ),
|
317 |
+
'manyErrors' => __( '%d configuration errors detected', 'contact-form-7' ),
|
318 |
+
'oneErrorInTab' => __( '1 configuration error detected in this tab panel', 'contact-form-7' ),
|
319 |
+
'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', 'contact-form-7' ),
|
320 |
+
'docUrl' => WPCF7_ConfigValidator::get_doc_link(),
|
321 |
+
),
|
322 |
+
);
|
323 |
|
324 |
if ( ( $post = wpcf7_get_current_contact_form() )
|
325 |
&& current_user_can( 'wpcf7_edit_contact_form', $post->id() )
|
326 |
&& wpcf7_validate_configuration() ) {
|
327 |
$config_validator = new WPCF7_ConfigValidator( $post );
|
328 |
+
$config_validator->restore();
|
329 |
+
$args['configValidator']['errors'] =
|
330 |
+
$config_validator->collect_error_messages();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
|
333 |
wp_localize_script( 'wpcf7-admin', '_wpcf7', $args );
|
411 |
<p><input type="submit" class="button" value="<?php echo esc_attr( $submit_text ); ?>" /></p>
|
412 |
</form>
|
413 |
|
414 |
+
<?php echo wpcf7_link( __( 'https://contactform7.com/configuration-validator-faq/', 'contact-form-7' ), __( 'FAQ about Configuration Validator', 'contact-form-7' ) ); ?>
|
415 |
|
416 |
</div>
|
417 |
<?php
|
487 |
}
|
488 |
|
489 |
if ( ! empty( $updated_message ) ) {
|
490 |
+
echo sprintf( '<div id="message" class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html( $updated_message ) );
|
491 |
+
return;
|
492 |
+
}
|
493 |
+
|
494 |
+
if ( 'failed' == $_REQUEST['message'] ) {
|
495 |
+
$updated_message = __( "There was an error saving the contact form.",
|
496 |
+
'contact-form-7' );
|
497 |
+
|
498 |
+
echo sprintf( '<div id="message" class="notice notice-error is-dismissible"><p>%s</p></div>', esc_html( $updated_message ) );
|
499 |
return;
|
500 |
}
|
501 |
|
526 |
add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 );
|
527 |
|
528 |
function wpcf7_plugin_action_links( $links, $file ) {
|
529 |
+
if ( $file != WPCF7_PLUGIN_BASENAME ) {
|
530 |
return $links;
|
531 |
+
}
|
532 |
|
533 |
$settings_link = '<a href="' . menu_page_url( 'wpcf7', false ) . '">'
|
534 |
. esc_html( __( 'Settings', 'contact-form-7' ) ) . '</a>';
|
575 |
esc_html( $message ) );
|
576 |
}
|
577 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
add_action( 'wpcf7_admin_warnings', 'wpcf7_notice_bulk_validate_config', 5 );
|
579 |
|
580 |
function wpcf7_notice_bulk_validate_config() {
|
admin/css/styles-rtl.css
CHANGED
@@ -1,8 +1,3 @@
|
|
1 |
-
#misc-publishing-actions .misc-pub-section::before {
|
2 |
-
right: -1px;
|
3 |
-
padding: 0 0 0 2px;
|
4 |
-
}
|
5 |
-
|
6 |
/*
|
7 |
* Tabs
|
8 |
*/
|
@@ -10,6 +5,10 @@
|
|
10 |
padding: 9px 10px 0 15px;
|
11 |
}
|
12 |
|
|
|
|
|
|
|
|
|
13 |
/*
|
14 |
* Form Tab
|
15 |
*/
|
|
|
|
|
|
|
|
|
|
|
1 |
/*
|
2 |
* Tabs
|
3 |
*/
|
5 |
padding: 9px 10px 0 15px;
|
6 |
}
|
7 |
|
8 |
+
#contact-form-editor-tabs li a span.dashicons {
|
9 |
+
padding: 6px 4px 4px 0;
|
10 |
+
}
|
11 |
+
|
12 |
/*
|
13 |
* Form Tab
|
14 |
*/
|
admin/css/styles.css
CHANGED
@@ -56,45 +56,31 @@ span.shortcode > input {
|
|
56 |
color: #23282d;
|
57 |
}
|
58 |
|
59 |
-
#misc-publishing-actions .misc-pub-section::before {
|
60 |
-
content: "\f488";
|
61 |
-
-moz-osx-font-smoothing: grayscale;
|
62 |
-
display: inline-block;
|
63 |
-
font: 20px/1 dashicons;
|
64 |
-
left: -1px;
|
65 |
-
padding: 0 2px 0 0;
|
66 |
-
position: relative;
|
67 |
-
text-decoration: none !important;
|
68 |
-
top: 0;
|
69 |
-
vertical-align: top;
|
70 |
-
color: #82878c;
|
71 |
-
}
|
72 |
-
|
73 |
-
#misc-publishing-actions .misc-pub-section.warning::before {
|
74 |
-
content: "\f534";
|
75 |
-
}
|
76 |
-
|
77 |
-
#misc-publishing-actions .misc-pub-section.warning a.external {
|
78 |
-
font-style: italic;
|
79 |
-
}
|
80 |
-
|
81 |
div.config-error, span.config-error, ul.config-error {
|
82 |
-
color: #
|
83 |
font-style: normal;
|
84 |
font-size: 13px;
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
87 |
ul.config-error {
|
88 |
margin: 0;
|
89 |
}
|
90 |
|
91 |
ul.config-error li {
|
|
|
92 |
padding: 0 4px;
|
93 |
margin: 0;
|
94 |
}
|
95 |
|
96 |
ul.config-error li a.external {
|
97 |
-
font-style:
|
|
|
|
|
|
|
98 |
}
|
99 |
|
100 |
[data-config-field][aria-invalid="true"] {
|
@@ -152,6 +138,16 @@ ul.config-error li a.external {
|
|
152 |
color: #000;
|
153 |
}
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
#contact-form-editor .contact-form-editor-panel h2 {
|
156 |
font-size: 18px;
|
157 |
font-weight: 400;
|
@@ -320,6 +316,10 @@ ul.config-error li a.external {
|
|
320 |
width: 38%;
|
321 |
}
|
322 |
|
|
|
|
|
|
|
|
|
323 |
/*
|
324 |
* Welcome Panel
|
325 |
*/
|
56 |
color: #23282d;
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
div.config-error, span.config-error, ul.config-error {
|
60 |
+
color: #444;
|
61 |
font-style: normal;
|
62 |
font-size: 13px;
|
63 |
}
|
64 |
|
65 |
+
div.config-error span.dashicons {
|
66 |
+
color: #82878c;
|
67 |
+
}
|
68 |
+
|
69 |
ul.config-error {
|
70 |
margin: 0;
|
71 |
}
|
72 |
|
73 |
ul.config-error li {
|
74 |
+
list-style: disc inside;
|
75 |
padding: 0 4px;
|
76 |
margin: 0;
|
77 |
}
|
78 |
|
79 |
ul.config-error li a.external {
|
80 |
+
font-style: normal;
|
81 |
+
font-weight: normal;
|
82 |
+
font-size: 18px;
|
83 |
+
vertical-align: middle;
|
84 |
}
|
85 |
|
86 |
[data-config-field][aria-invalid="true"] {
|
138 |
color: #000;
|
139 |
}
|
140 |
|
141 |
+
#contact-form-editor-tabs li a span.dashicons {
|
142 |
+
font-style: normal;
|
143 |
+
padding: 6px 0 4px 4px;
|
144 |
+
color: #82878c;
|
145 |
+
}
|
146 |
+
|
147 |
+
#contact-form-editor-tabs li.ui-tabs-active a span.dashicons {
|
148 |
+
display: none;
|
149 |
+
}
|
150 |
+
|
151 |
#contact-form-editor .contact-form-editor-panel h2 {
|
152 |
font-size: 18px;
|
153 |
font-weight: 400;
|
316 |
width: 38%;
|
317 |
}
|
318 |
|
319 |
+
.wp-list-table .config-error span.dashicons {
|
320 |
+
color: #82878c;
|
321 |
+
}
|
322 |
+
|
323 |
/*
|
324 |
* Welcome Panel
|
325 |
*/
|
admin/edit-contact-form.php
CHANGED
@@ -63,7 +63,7 @@ if ( $post ) :
|
|
63 |
}
|
64 |
?>
|
65 |
<input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" />
|
66 |
-
<input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale ); ?>" />
|
67 |
<input type="hidden" id="hiddenaction" name="action" value="save" />
|
68 |
<input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" />
|
69 |
|
@@ -163,9 +163,9 @@ if ( $post ) :
|
|
163 |
<h3><?php echo esc_html( __( 'Information', 'contact-form-7' ) ); ?></h3>
|
164 |
<div class="inside">
|
165 |
<ul>
|
166 |
-
<li><?php echo wpcf7_link( __( '
|
167 |
-
<li><?php echo wpcf7_link( __( '
|
168 |
-
<li><?php echo wpcf7_link( __( '
|
169 |
</ul>
|
170 |
</div>
|
171 |
</div><!-- #informationdiv -->
|
63 |
}
|
64 |
?>
|
65 |
<input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" />
|
66 |
+
<input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale() ); ?>" />
|
67 |
<input type="hidden" id="hiddenaction" name="action" value="save" />
|
68 |
<input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" />
|
69 |
|
163 |
<h3><?php echo esc_html( __( 'Information', 'contact-form-7' ) ); ?></h3>
|
164 |
<div class="inside">
|
165 |
<ul>
|
166 |
+
<li><?php echo wpcf7_link( __( 'https://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ); ?></li>
|
167 |
+
<li><?php echo wpcf7_link( __( 'https://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ); ?></li>
|
168 |
+
<li><?php echo wpcf7_link( __( 'https://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ); ?></li>
|
169 |
</ul>
|
170 |
</div>
|
171 |
</div><!-- #informationdiv -->
|
admin/includes/admin-functions.php
CHANGED
@@ -20,147 +20,3 @@ function wpcf7_add_tag_generator( $name, $title, $elm_id, $callback, $options =
|
|
20 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
21 |
return $tag_generator->add( $name, $title, $callback, $options );
|
22 |
}
|
23 |
-
|
24 |
-
function wpcf7_save_contact_form( $post_id = -1 ) {
|
25 |
-
if ( -1 != $post_id ) {
|
26 |
-
$contact_form = wpcf7_contact_form( $post_id );
|
27 |
-
}
|
28 |
-
|
29 |
-
if ( empty( $contact_form ) ) {
|
30 |
-
$contact_form = WPCF7_ContactForm::get_template();
|
31 |
-
}
|
32 |
-
|
33 |
-
if ( isset( $_POST['post_title'] ) ) {
|
34 |
-
$contact_form->set_title( $_POST['post_title'] );
|
35 |
-
}
|
36 |
-
|
37 |
-
if ( isset( $_POST['wpcf7-locale'] ) ) {
|
38 |
-
$locale = trim( $_POST['wpcf7-locale'] );
|
39 |
-
|
40 |
-
if ( wpcf7_is_valid_locale( $locale ) ) {
|
41 |
-
$contact_form->locale = $locale;
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
$properties = $contact_form->get_properties();
|
46 |
-
|
47 |
-
if ( isset( $_POST['wpcf7-form'] ) ) {
|
48 |
-
$properties['form'] = trim( $_POST['wpcf7-form'] );
|
49 |
-
}
|
50 |
-
|
51 |
-
$mail = $properties['mail'];
|
52 |
-
|
53 |
-
if ( isset( $_POST['wpcf7-mail-subject'] ) ) {
|
54 |
-
$mail['subject'] = trim( $_POST['wpcf7-mail-subject'] );
|
55 |
-
}
|
56 |
-
|
57 |
-
if ( isset( $_POST['wpcf7-mail-sender'] ) ) {
|
58 |
-
$mail['sender'] = trim( $_POST['wpcf7-mail-sender'] );
|
59 |
-
}
|
60 |
-
|
61 |
-
if ( isset( $_POST['wpcf7-mail-body'] ) ) {
|
62 |
-
$mail['body'] = trim( $_POST['wpcf7-mail-body'] );
|
63 |
-
}
|
64 |
-
|
65 |
-
if ( isset( $_POST['wpcf7-mail-recipient'] ) ) {
|
66 |
-
$mail['recipient'] = trim( $_POST['wpcf7-mail-recipient'] );
|
67 |
-
}
|
68 |
-
|
69 |
-
if ( isset( $_POST['wpcf7-mail-additional-headers'] ) ) {
|
70 |
-
$headers = '';
|
71 |
-
$tempheaders = str_replace(
|
72 |
-
"\r\n", "\n", $_POST['wpcf7-mail-additional-headers'] );
|
73 |
-
$tempheaders = explode( "\n", $tempheaders );
|
74 |
-
|
75 |
-
foreach ( $tempheaders as $header ) {
|
76 |
-
$header = trim( $header );
|
77 |
-
|
78 |
-
if ( '' !== $header ) {
|
79 |
-
$headers .= $header . "\n";
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
$mail['additional_headers'] = trim( $headers );
|
84 |
-
}
|
85 |
-
|
86 |
-
if ( isset( $_POST['wpcf7-mail-attachments'] ) ) {
|
87 |
-
$mail['attachments'] = trim( $_POST['wpcf7-mail-attachments'] );
|
88 |
-
}
|
89 |
-
|
90 |
-
$mail['use_html'] = ! empty( $_POST['wpcf7-mail-use-html'] );
|
91 |
-
$mail['exclude_blank'] = ! empty( $_POST['wpcf7-mail-exclude-blank'] );
|
92 |
-
|
93 |
-
$properties['mail'] = $mail;
|
94 |
-
|
95 |
-
$mail_2 = $properties['mail_2'];
|
96 |
-
|
97 |
-
$mail_2['active'] = ! empty( $_POST['wpcf7-mail-2-active'] );
|
98 |
-
|
99 |
-
if ( isset( $_POST['wpcf7-mail-2-subject'] ) ) {
|
100 |
-
$mail_2['subject'] = trim( $_POST['wpcf7-mail-2-subject'] );
|
101 |
-
}
|
102 |
-
|
103 |
-
if ( isset( $_POST['wpcf7-mail-2-sender'] ) ) {
|
104 |
-
$mail_2['sender'] = trim( $_POST['wpcf7-mail-2-sender'] );
|
105 |
-
}
|
106 |
-
|
107 |
-
if ( isset( $_POST['wpcf7-mail-2-body'] ) ) {
|
108 |
-
$mail_2['body'] = trim( $_POST['wpcf7-mail-2-body'] );
|
109 |
-
}
|
110 |
-
|
111 |
-
if ( isset( $_POST['wpcf7-mail-2-recipient'] ) ) {
|
112 |
-
$mail_2['recipient'] = trim( $_POST['wpcf7-mail-2-recipient'] );
|
113 |
-
}
|
114 |
-
|
115 |
-
if ( isset( $_POST['wpcf7-mail-2-additional-headers'] ) ) {
|
116 |
-
$headers = '';
|
117 |
-
$tempheaders = str_replace(
|
118 |
-
"\r\n", "\n", $_POST['wpcf7-mail-2-additional-headers'] );
|
119 |
-
$tempheaders = explode( "\n", $tempheaders );
|
120 |
-
|
121 |
-
foreach ( $tempheaders as $header ) {
|
122 |
-
$header = trim( $header );
|
123 |
-
|
124 |
-
if ( '' !== $header ) {
|
125 |
-
$headers .= $header . "\n";
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
$mail_2['additional_headers'] = trim( $headers );
|
130 |
-
}
|
131 |
-
|
132 |
-
if ( isset( $_POST['wpcf7-mail-2-attachments'] ) ) {
|
133 |
-
$mail_2['attachments'] = trim( $_POST['wpcf7-mail-2-attachments'] );
|
134 |
-
}
|
135 |
-
|
136 |
-
$mail_2['use_html'] = ! empty( $_POST['wpcf7-mail-2-use-html'] );
|
137 |
-
$mail_2['exclude_blank'] = ! empty( $_POST['wpcf7-mail-2-exclude-blank'] );
|
138 |
-
|
139 |
-
$properties['mail_2'] = $mail_2;
|
140 |
-
|
141 |
-
foreach ( wpcf7_messages() as $key => $arr ) {
|
142 |
-
$field_name = 'wpcf7-message-' . strtr( $key, '_', '-' );
|
143 |
-
|
144 |
-
if ( isset( $_POST[$field_name] ) ) {
|
145 |
-
$properties['messages'][$key] = trim( $_POST[$field_name] );
|
146 |
-
}
|
147 |
-
}
|
148 |
-
|
149 |
-
if ( isset( $_POST['wpcf7-additional-settings'] ) ) {
|
150 |
-
$properties['additional_settings'] = trim(
|
151 |
-
$_POST['wpcf7-additional-settings'] );
|
152 |
-
}
|
153 |
-
|
154 |
-
$contact_form->set_properties( $properties );
|
155 |
-
|
156 |
-
do_action( 'wpcf7_save_contact_form', $contact_form );
|
157 |
-
|
158 |
-
$post_id = $contact_form->save();
|
159 |
-
|
160 |
-
if ( wpcf7_validate_configuration() ) {
|
161 |
-
$config_validator = new WPCF7_ConfigValidator( $contact_form );
|
162 |
-
$config_validator->validate();
|
163 |
-
}
|
164 |
-
|
165 |
-
return $post_id;
|
166 |
-
}
|
20 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
21 |
return $tag_generator->add( $name, $title, $callback, $options );
|
22 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/includes/class-contact-forms-list-table.php
CHANGED
@@ -12,7 +12,8 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
12 |
'title' => __( 'Title', 'contact-form-7' ),
|
13 |
'shortcode' => __( 'Shortcode', 'contact-form-7' ),
|
14 |
'author' => __( 'Author', 'contact-form-7' ),
|
15 |
-
'date' => __( 'Date', 'contact-form-7' )
|
|
|
16 |
|
17 |
return $columns;
|
18 |
}
|
@@ -21,7 +22,8 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
21 |
parent::__construct( array(
|
22 |
'singular' => 'post',
|
23 |
'plural' => 'posts',
|
24 |
-
'ajax' => false
|
|
|
25 |
}
|
26 |
|
27 |
function prepare_items() {
|
@@ -34,25 +36,29 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
34 |
'posts_per_page' => $per_page,
|
35 |
'orderby' => 'title',
|
36 |
'order' => 'ASC',
|
37 |
-
'offset' => ( $this->get_pagenum() - 1 ) * $per_page
|
|
|
38 |
|
39 |
-
if ( ! empty( $_REQUEST['s'] ) )
|
40 |
$args['s'] = $_REQUEST['s'];
|
|
|
41 |
|
42 |
if ( ! empty( $_REQUEST['orderby'] ) ) {
|
43 |
-
if ( 'title' == $_REQUEST['orderby'] )
|
44 |
$args['orderby'] = 'title';
|
45 |
-
elseif ( 'author' == $_REQUEST['orderby'] )
|
46 |
$args['orderby'] = 'author';
|
47 |
-
elseif ( 'date' == $_REQUEST['orderby'] )
|
48 |
$args['orderby'] = 'date';
|
|
|
49 |
}
|
50 |
|
51 |
if ( ! empty( $_REQUEST['order'] ) ) {
|
52 |
-
if ( 'asc' == strtolower( $_REQUEST['order'] ) )
|
53 |
$args['order'] = 'ASC';
|
54 |
-
elseif ( 'desc' == strtolower( $_REQUEST['order'] ) )
|
55 |
$args['order'] = 'DESC';
|
|
|
56 |
}
|
57 |
|
58 |
$this->items = WPCF7_ContactForm::find( $args );
|
@@ -63,7 +69,8 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
63 |
$this->set_pagination_args( array(
|
64 |
'total_items' => $total_items,
|
65 |
'total_pages' => $total_pages,
|
66 |
-
'per_page' => $per_page
|
|
|
67 |
}
|
68 |
|
69 |
function get_columns() {
|
@@ -74,14 +81,16 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
74 |
$columns = array(
|
75 |
'title' => array( 'title', true ),
|
76 |
'author' => array( 'author', false ),
|
77 |
-
'date' => array( 'date', false )
|
|
|
78 |
|
79 |
return $columns;
|
80 |
}
|
81 |
|
82 |
function get_bulk_actions() {
|
83 |
$actions = array(
|
84 |
-
'delete' => __( 'Delete', 'contact-form-7' )
|
|
|
85 |
|
86 |
return $actions;
|
87 |
}
|
@@ -106,23 +115,25 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
106 |
esc_url( $edit_link ),
|
107 |
esc_attr( sprintf( __( 'Edit “%s”', 'contact-form-7' ),
|
108 |
$item->title() ) ),
|
109 |
-
esc_html( $item->title() )
|
|
|
110 |
|
111 |
$output = sprintf( '<strong>%s</strong>', $output );
|
112 |
|
113 |
if ( wpcf7_validate_configuration()
|
114 |
&& current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
|
115 |
$config_validator = new WPCF7_ConfigValidator( $item );
|
|
|
116 |
|
117 |
if ( $count_errors = $config_validator->count_errors() ) {
|
118 |
$error_notice = sprintf(
|
119 |
_n(
|
120 |
-
'%s configuration error
|
121 |
-
'%s configuration errors
|
122 |
$count_errors, 'contact-form-7' ),
|
123 |
number_format_i18n( $count_errors ) );
|
124 |
$output .= sprintf(
|
125 |
-
'<div class="config-error"
|
126 |
$error_notice );
|
127 |
}
|
128 |
}
|
@@ -140,7 +151,9 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
140 |
$actions = array_merge( $actions, array(
|
141 |
'copy' => sprintf( '<a href="%1$s">%2$s</a>',
|
142 |
esc_url( $copy_link ),
|
143 |
-
esc_html( __( 'Duplicate', 'contact-form-7' ) )
|
|
|
|
|
144 |
}
|
145 |
|
146 |
$output .= $this->row_actions( $actions );
|
@@ -182,19 +195,24 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
182 |
function column_date( $item ) {
|
183 |
$post = get_post( $item->id() );
|
184 |
|
185 |
-
if ( ! $post )
|
186 |
return;
|
|
|
187 |
|
188 |
-
$t_time = mysql2date( __( 'Y/m/d g:i:s A', 'contact-form-7' ),
|
|
|
189 |
$m_time = $post->post_date;
|
190 |
-
$time = mysql2date( 'G', $post->post_date )
|
|
|
191 |
|
192 |
$time_diff = time() - $time;
|
193 |
|
194 |
-
if ( $time_diff > 0 && $time_diff < 24*60*60 )
|
195 |
-
$h_time = sprintf(
|
196 |
-
|
|
|
197 |
$h_time = mysql2date( __( 'Y/m/d', 'contact-form-7' ), $m_time );
|
|
|
198 |
|
199 |
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
|
200 |
}
|
12 |
'title' => __( 'Title', 'contact-form-7' ),
|
13 |
'shortcode' => __( 'Shortcode', 'contact-form-7' ),
|
14 |
'author' => __( 'Author', 'contact-form-7' ),
|
15 |
+
'date' => __( 'Date', 'contact-form-7' ),
|
16 |
+
);
|
17 |
|
18 |
return $columns;
|
19 |
}
|
22 |
parent::__construct( array(
|
23 |
'singular' => 'post',
|
24 |
'plural' => 'posts',
|
25 |
+
'ajax' => false,
|
26 |
+
) );
|
27 |
}
|
28 |
|
29 |
function prepare_items() {
|
36 |
'posts_per_page' => $per_page,
|
37 |
'orderby' => 'title',
|
38 |
'order' => 'ASC',
|
39 |
+
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
|
40 |
+
);
|
41 |
|
42 |
+
if ( ! empty( $_REQUEST['s'] ) ) {
|
43 |
$args['s'] = $_REQUEST['s'];
|
44 |
+
}
|
45 |
|
46 |
if ( ! empty( $_REQUEST['orderby'] ) ) {
|
47 |
+
if ( 'title' == $_REQUEST['orderby'] ) {
|
48 |
$args['orderby'] = 'title';
|
49 |
+
} elseif ( 'author' == $_REQUEST['orderby'] ) {
|
50 |
$args['orderby'] = 'author';
|
51 |
+
} elseif ( 'date' == $_REQUEST['orderby'] ) {
|
52 |
$args['orderby'] = 'date';
|
53 |
+
}
|
54 |
}
|
55 |
|
56 |
if ( ! empty( $_REQUEST['order'] ) ) {
|
57 |
+
if ( 'asc' == strtolower( $_REQUEST['order'] ) ) {
|
58 |
$args['order'] = 'ASC';
|
59 |
+
} elseif ( 'desc' == strtolower( $_REQUEST['order'] ) ) {
|
60 |
$args['order'] = 'DESC';
|
61 |
+
}
|
62 |
}
|
63 |
|
64 |
$this->items = WPCF7_ContactForm::find( $args );
|
69 |
$this->set_pagination_args( array(
|
70 |
'total_items' => $total_items,
|
71 |
'total_pages' => $total_pages,
|
72 |
+
'per_page' => $per_page,
|
73 |
+
) );
|
74 |
}
|
75 |
|
76 |
function get_columns() {
|
81 |
$columns = array(
|
82 |
'title' => array( 'title', true ),
|
83 |
'author' => array( 'author', false ),
|
84 |
+
'date' => array( 'date', false ),
|
85 |
+
);
|
86 |
|
87 |
return $columns;
|
88 |
}
|
89 |
|
90 |
function get_bulk_actions() {
|
91 |
$actions = array(
|
92 |
+
'delete' => __( 'Delete', 'contact-form-7' ),
|
93 |
+
);
|
94 |
|
95 |
return $actions;
|
96 |
}
|
115 |
esc_url( $edit_link ),
|
116 |
esc_attr( sprintf( __( 'Edit “%s”', 'contact-form-7' ),
|
117 |
$item->title() ) ),
|
118 |
+
esc_html( $item->title() )
|
119 |
+
);
|
120 |
|
121 |
$output = sprintf( '<strong>%s</strong>', $output );
|
122 |
|
123 |
if ( wpcf7_validate_configuration()
|
124 |
&& current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
|
125 |
$config_validator = new WPCF7_ConfigValidator( $item );
|
126 |
+
$config_validator->restore();
|
127 |
|
128 |
if ( $count_errors = $config_validator->count_errors() ) {
|
129 |
$error_notice = sprintf(
|
130 |
_n(
|
131 |
+
'%s configuration error detected',
|
132 |
+
'%s configuration errors detected',
|
133 |
$count_errors, 'contact-form-7' ),
|
134 |
number_format_i18n( $count_errors ) );
|
135 |
$output .= sprintf(
|
136 |
+
'<div class="config-error"><span class="dashicons dashicons-warning"></span> %s</div>',
|
137 |
$error_notice );
|
138 |
}
|
139 |
}
|
151 |
$actions = array_merge( $actions, array(
|
152 |
'copy' => sprintf( '<a href="%1$s">%2$s</a>',
|
153 |
esc_url( $copy_link ),
|
154 |
+
esc_html( __( 'Duplicate', 'contact-form-7' ) )
|
155 |
+
),
|
156 |
+
) );
|
157 |
}
|
158 |
|
159 |
$output .= $this->row_actions( $actions );
|
195 |
function column_date( $item ) {
|
196 |
$post = get_post( $item->id() );
|
197 |
|
198 |
+
if ( ! $post ) {
|
199 |
return;
|
200 |
+
}
|
201 |
|
202 |
+
$t_time = mysql2date( __( 'Y/m/d g:i:s A', 'contact-form-7' ),
|
203 |
+
$post->post_date, true );
|
204 |
$m_time = $post->post_date;
|
205 |
+
$time = mysql2date( 'G', $post->post_date )
|
206 |
+
- get_option( 'gmt_offset' ) * 3600;
|
207 |
|
208 |
$time_diff = time() - $time;
|
209 |
|
210 |
+
if ( $time_diff > 0 && $time_diff < 24*60*60 ) {
|
211 |
+
$h_time = sprintf(
|
212 |
+
__( '%s ago', 'contact-form-7' ), human_time_diff( $time ) );
|
213 |
+
} else {
|
214 |
$h_time = mysql2date( __( 'Y/m/d', 'contact-form-7' ), $m_time );
|
215 |
+
}
|
216 |
|
217 |
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
|
218 |
}
|
admin/includes/editor.php
CHANGED
@@ -13,7 +13,8 @@ class WPCF7_Editor {
|
|
13 |
if ( wpcf7_is_name( $id ) ) {
|
14 |
$this->panels[$id] = array(
|
15 |
'title' => $title,
|
16 |
-
'callback' => $callback
|
|
|
17 |
}
|
18 |
}
|
19 |
|
@@ -34,10 +35,19 @@ class WPCF7_Editor {
|
|
34 |
foreach ( $this->panels as $id => $panel ) {
|
35 |
echo sprintf( '<div class="contact-form-editor-panel" id="%1$s">',
|
36 |
esc_attr( $id ) );
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
38 |
echo '</div>';
|
39 |
}
|
40 |
}
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
function wpcf7_editor_panel_form( $post ) {
|
@@ -62,7 +72,8 @@ function wpcf7_editor_panel_mail( $post ) {
|
|
62 |
'id' => 'wpcf7-mail-2',
|
63 |
'name' => 'mail_2',
|
64 |
'title' => __( 'Mail (2)', 'contact-form-7' ),
|
65 |
-
'use' => __( 'Use Mail (2)', 'contact-form-7' )
|
|
|
66 |
}
|
67 |
|
68 |
function wpcf7_editor_box_mail( $post, $args = '' ) {
|
@@ -70,14 +81,22 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
|
|
70 |
'id' => 'wpcf7-mail',
|
71 |
'name' => 'mail',
|
72 |
'title' => __( 'Mail', 'contact-form-7' ),
|
73 |
-
'use' => null
|
|
|
74 |
|
75 |
$id = esc_attr( $args['id'] );
|
76 |
|
77 |
$mail = wp_parse_args( $post->prop( $args['name'] ), array(
|
78 |
-
'active' => false,
|
79 |
-
'
|
80 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
?>
|
83 |
<div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
|
@@ -86,7 +105,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
|
|
86 |
<?php
|
87 |
if ( ! empty( $args['use'] ) ) :
|
88 |
?>
|
89 |
-
<label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id;
|
90 |
<p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
|
91 |
<?php
|
92 |
endif;
|
@@ -102,7 +121,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
|
|
102 |
<label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
|
103 |
</th>
|
104 |
<td>
|
105 |
-
<input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id;
|
106 |
</td>
|
107 |
</tr>
|
108 |
|
@@ -111,7 +130,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
|
|
111 |
<label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
|
112 |
</th>
|
113 |
<td>
|
114 |
-
<input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id;
|
115 |
</td>
|
116 |
</tr>
|
117 |
|
@@ -120,7 +139,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
|
|
120 |
<label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
|
121 |
</th>
|
122 |
<td>
|
123 |
-
<input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id;
|
124 |
</td>
|
125 |
</tr>
|
126 |
|
@@ -129,7 +148,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
|
|
129 |
<label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional Headers', 'contact-form-7' ) ); ?></label>
|
130 |
</th>
|
131 |
<td>
|
132 |
-
<textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id;
|
133 |
</td>
|
134 |
</tr>
|
135 |
|
@@ -138,11 +157,11 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
|
|
138 |
<label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message Body', 'contact-form-7' ) ); ?></label>
|
139 |
</th>
|
140 |
<td>
|
141 |
-
<textarea id="<?php echo $id; ?>-body" name="<?php echo $id;
|
142 |
|
143 |
-
<p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id;
|
144 |
|
145 |
-
<p><label for="<?php echo $id; ?>-use-html"><input type="checkbox" id="<?php echo $id; ?>-use-html" name="<?php echo $id;
|
146 |
</td>
|
147 |
</tr>
|
148 |
|
@@ -151,7 +170,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
|
|
151 |
<label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File Attachments', 'contact-form-7' ) ); ?></label>
|
152 |
</th>
|
153 |
<td>
|
154 |
-
<textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id;
|
155 |
</td>
|
156 |
</tr>
|
157 |
</tbody>
|
@@ -176,12 +195,13 @@ function wpcf7_editor_panel_messages( $post ) {
|
|
176 |
<?php
|
177 |
|
178 |
foreach ( $messages as $key => $arr ) {
|
179 |
-
$
|
|
|
180 |
|
181 |
?>
|
182 |
<p class="description">
|
183 |
-
<label for="<?php echo $
|
184 |
-
<input type="text" id="<?php echo $
|
185 |
</label>
|
186 |
</p>
|
187 |
<?php
|
@@ -193,7 +213,7 @@ function wpcf7_editor_panel_messages( $post ) {
|
|
193 |
|
194 |
function wpcf7_editor_panel_additional_settings( $post ) {
|
195 |
$desc_link = wpcf7_link(
|
196 |
-
__( '
|
197 |
__( 'Additional Settings', 'contact-form-7' ) );
|
198 |
$description = __( "You can add customization code snippets here. For details, see %s.", 'contact-form-7' );
|
199 |
$description = sprintf( esc_html( $description ), $desc_link );
|
13 |
if ( wpcf7_is_name( $id ) ) {
|
14 |
$this->panels[$id] = array(
|
15 |
'title' => $title,
|
16 |
+
'callback' => $callback,
|
17 |
+
);
|
18 |
}
|
19 |
}
|
20 |
|
35 |
foreach ( $this->panels as $id => $panel ) {
|
36 |
echo sprintf( '<div class="contact-form-editor-panel" id="%1$s">',
|
37 |
esc_attr( $id ) );
|
38 |
+
|
39 |
+
if ( is_callable( $panel['callback'] ) ) {
|
40 |
+
$this->notice( $id, $panel );
|
41 |
+
call_user_func( $panel['callback'], $this->contact_form );
|
42 |
+
}
|
43 |
+
|
44 |
echo '</div>';
|
45 |
}
|
46 |
}
|
47 |
+
|
48 |
+
public function notice( $id, $panel ) {
|
49 |
+
echo '<div class="config-error"></div>';
|
50 |
+
}
|
51 |
}
|
52 |
|
53 |
function wpcf7_editor_panel_form( $post ) {
|
72 |
'id' => 'wpcf7-mail-2',
|
73 |
'name' => 'mail_2',
|
74 |
'title' => __( 'Mail (2)', 'contact-form-7' ),
|
75 |
+
'use' => __( 'Use Mail (2)', 'contact-form-7' ),
|
76 |
+
) );
|
77 |
}
|
78 |
|
79 |
function wpcf7_editor_box_mail( $post, $args = '' ) {
|
81 |
'id' => 'wpcf7-mail',
|
82 |
'name' => 'mail',
|
83 |
'title' => __( 'Mail', 'contact-form-7' ),
|
84 |
+
'use' => null,
|
85 |
+
) );
|
86 |
|
87 |
$id = esc_attr( $args['id'] );
|
88 |
|
89 |
$mail = wp_parse_args( $post->prop( $args['name'] ), array(
|
90 |
+
'active' => false,
|
91 |
+
'recipient' => '',
|
92 |
+
'sender' => '',
|
93 |
+
'subject' => '',
|
94 |
+
'body' => '',
|
95 |
+
'additional_headers' => '',
|
96 |
+
'attachments' => '',
|
97 |
+
'use_html' => false,
|
98 |
+
'exclude_blank' => false,
|
99 |
+
) );
|
100 |
|
101 |
?>
|
102 |
<div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
|
105 |
<?php
|
106 |
if ( ! empty( $args['use'] ) ) :
|
107 |
?>
|
108 |
+
<label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>[active]" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
|
109 |
<p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
|
110 |
<?php
|
111 |
endif;
|
121 |
<label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
|
122 |
</th>
|
123 |
<td>
|
124 |
+
<input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>[recipient]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" data-config-field="<?php echo sprintf( '%s.recipient', esc_attr( $args['name'] ) ); ?>" />
|
125 |
</td>
|
126 |
</tr>
|
127 |
|
130 |
<label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
|
131 |
</th>
|
132 |
<td>
|
133 |
+
<input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>[sender]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" data-config-field="<?php echo sprintf( '%s.sender', esc_attr( $args['name'] ) ); ?>" />
|
134 |
</td>
|
135 |
</tr>
|
136 |
|
139 |
<label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
|
140 |
</th>
|
141 |
<td>
|
142 |
+
<input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>[subject]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" data-config-field="<?php echo sprintf( '%s.subject', esc_attr( $args['name'] ) ); ?>" />
|
143 |
</td>
|
144 |
</tr>
|
145 |
|
148 |
<label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional Headers', 'contact-form-7' ) ); ?></label>
|
149 |
</th>
|
150 |
<td>
|
151 |
+
<textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>[additional_headers]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.additional_headers', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
|
152 |
</td>
|
153 |
</tr>
|
154 |
|
157 |
<label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message Body', 'contact-form-7' ) ); ?></label>
|
158 |
</th>
|
159 |
<td>
|
160 |
+
<textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>[body]" cols="100" rows="18" class="large-text code" data-config-field="<?php echo sprintf( '%s.body', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
|
161 |
|
162 |
+
<p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>[exclude_blank]" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
|
163 |
|
164 |
+
<p><label for="<?php echo $id; ?>-use-html"><input type="checkbox" id="<?php echo $id; ?>-use-html" name="<?php echo $id; ?>[use_html]" value="1"<?php echo ( $mail['use_html'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Use HTML content type', 'contact-form-7' ) ); ?></label></p>
|
165 |
</td>
|
166 |
</tr>
|
167 |
|
170 |
<label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File Attachments', 'contact-form-7' ) ); ?></label>
|
171 |
</th>
|
172 |
<td>
|
173 |
+
<textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>[attachments]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.attachments', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
|
174 |
</td>
|
175 |
</tr>
|
176 |
</tbody>
|
195 |
<?php
|
196 |
|
197 |
foreach ( $messages as $key => $arr ) {
|
198 |
+
$field_id = sprintf( 'wpcf7-message-%s', strtr( $key, '_', '-' ) );
|
199 |
+
$field_name = sprintf( 'wpcf7-messages[%s]', $key );
|
200 |
|
201 |
?>
|
202 |
<p class="description">
|
203 |
+
<label for="<?php echo $field_id; ?>"><?php echo esc_html( $arr['description'] ); ?><br />
|
204 |
+
<input type="text" id="<?php echo $field_id; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>" data-config-field="<?php echo sprintf( 'messages.%s', esc_attr( $key ) ); ?>" />
|
205 |
</label>
|
206 |
</p>
|
207 |
<?php
|
213 |
|
214 |
function wpcf7_editor_panel_additional_settings( $post ) {
|
215 |
$desc_link = wpcf7_link(
|
216 |
+
__( 'https://contactform7.com/additional-settings/', 'contact-form-7' ),
|
217 |
__( 'Additional Settings', 'contact-form-7' ) );
|
218 |
$description = __( "You can add customization code snippets here. For details, see %s.", 'contact-form-7' );
|
219 |
$description = sprintf( esc_html( $description ), $desc_link );
|
admin/includes/help-tabs.php
CHANGED
@@ -89,9 +89,9 @@ class WPCF7_Help_Tabs {
|
|
89 |
|
90 |
public function sidebar() {
|
91 |
$content = '<p><strong>' . __( 'For more information:', 'contact-form-7' ) . '</strong></p>';
|
92 |
-
$content .= '<p>' . wpcf7_link( __( '
|
93 |
-
$content .= '<p>' . wpcf7_link( __( '
|
94 |
-
$content .= '<p>' . wpcf7_link( __( '
|
95 |
|
96 |
$this->screen->set_help_sidebar( $content );
|
97 |
}
|
89 |
|
90 |
public function sidebar() {
|
91 |
$content = '<p><strong>' . __( 'For more information:', 'contact-form-7' ) . '</strong></p>';
|
92 |
+
$content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ) . '</p>';
|
93 |
+
$content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ) . '</p>';
|
94 |
+
$content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ) . '</p>';
|
95 |
|
96 |
$this->screen->set_help_sidebar( $content );
|
97 |
}
|
admin/includes/tag-generator.php
CHANGED
@@ -27,7 +27,8 @@ class WPCF7_TagGenerator {
|
|
27 |
'title' => $title,
|
28 |
'content' => 'tag-generator-panel-' . $id,
|
29 |
'options' => $options,
|
30 |
-
'callback' => $callback
|
|
|
31 |
|
32 |
return true;
|
33 |
}
|
@@ -56,7 +57,8 @@ class WPCF7_TagGenerator {
|
|
56 |
$options = array_merge( $options, array(
|
57 |
'id' => $id,
|
58 |
'title' => $panel['title'],
|
59 |
-
'content' => $panel['content']
|
|
|
60 |
|
61 |
if ( is_callable( $callback ) ) {
|
62 |
echo sprintf( '<div id="%s" class="hidden">',
|
27 |
'title' => $title,
|
28 |
'content' => 'tag-generator-panel-' . $id,
|
29 |
'options' => $options,
|
30 |
+
'callback' => $callback,
|
31 |
+
);
|
32 |
|
33 |
return true;
|
34 |
}
|
57 |
$options = array_merge( $options, array(
|
58 |
'id' => $id,
|
59 |
'title' => $panel['title'],
|
60 |
+
'content' => $panel['content'],
|
61 |
+
) );
|
62 |
|
63 |
if ( is_callable( $callback ) ) {
|
64 |
echo sprintf( '<div id="%s" class="hidden">',
|
admin/includes/welcome-panel.php
CHANGED
@@ -23,7 +23,7 @@ function wpcf7_welcome_panel() {
|
|
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 |
|
26 |
-
<p><?php echo sprintf( esc_html( __( 'Contact Form 7 supports spam-filtering with %1$s. Intelligent %2$s blocks annoying spambots. Plus, using %3$s, you can block messages containing specified keywords or those sent from specified IP addresses.', 'contact-form-7' ) ), wpcf7_link( __( '
|
27 |
</div>
|
28 |
|
29 |
<div class="welcome-panel-column">
|
@@ -31,7 +31,7 @@ function wpcf7_welcome_panel() {
|
|
31 |
|
32 |
<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>
|
33 |
|
34 |
-
<p><?php echo sprintf( esc_html( __( 'Install a message storage plugin before this happens to you. %s saves all messages through contact forms into the database. Flamingo is a free WordPress plugin created by the same author as Contact Form 7.', 'contact-form-7' ) ), wpcf7_link( __( '
|
35 |
</div>
|
36 |
|
37 |
</div>
|
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 |
|
26 |
+
<p><?php echo sprintf( esc_html( __( 'Contact Form 7 supports spam-filtering with %1$s. Intelligent %2$s blocks annoying spambots. Plus, using %3$s, you can block messages containing specified keywords or those sent from specified IP addresses.', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), __( 'Akismet', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/comment-blacklist/', 'contact-form-7' ), __( 'comment blacklist', 'contact-form-7' ) ) ); ?></p>
|
27 |
</div>
|
28 |
|
29 |
<div class="welcome-panel-column">
|
31 |
|
32 |
<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>
|
33 |
|
34 |
+
<p><?php echo sprintf( esc_html( __( 'Install a message storage plugin before this happens to you. %s saves all messages through contact forms into the database. Flamingo is a free WordPress plugin created by the same author as Contact Form 7.', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ), __( 'Flamingo', 'contact-form-7' ) ) ); ?></p>
|
35 |
</div>
|
36 |
|
37 |
</div>
|
admin/js/scripts.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
(function($) {
|
2 |
|
3 |
'use strict';
|
4 |
|
5 |
-
if (typeof _wpcf7
|
6 |
-
|
7 |
}
|
8 |
|
9 |
-
$(function() {
|
10 |
-
var welcomePanel = $('#welcome-panel');
|
11 |
var updateWelcomePanel;
|
12 |
|
13 |
updateWelcomePanel = function( visible ) {
|
@@ -15,150 +15,267 @@
|
|
15 |
action: 'wpcf7-update-welcome-panel',
|
16 |
visible: visible,
|
17 |
welcomepanelnonce: $( '#welcomepanelnonce' ).val()
|
18 |
-
});
|
19 |
};
|
20 |
|
21 |
-
$('a.welcome-panel-close', welcomePanel).click(function(event) {
|
22 |
event.preventDefault();
|
23 |
-
welcomePanel.addClass('hidden');
|
24 |
updateWelcomePanel( 0 );
|
25 |
-
});
|
26 |
|
27 |
-
$('#contact-form-editor').tabs({
|
28 |
active: _wpcf7.activeTab,
|
29 |
-
activate: function(event, ui) {
|
30 |
-
$('#active-tab').val(ui.newTab.index());
|
31 |
}
|
32 |
-
});
|
33 |
-
|
34 |
-
$('#contact-form-editor-tabs').focusin(function(event) {
|
35 |
-
$('#contact-form-editor .keyboard-interaction').css(
|
36 |
-
'visibility', 'visible');
|
37 |
-
}).focusout(function(event) {
|
38 |
-
$('#contact-form-editor .keyboard-interaction').css(
|
39 |
-
'visibility', 'hidden');
|
40 |
-
});
|
41 |
-
|
42 |
-
$('input:checkbox.toggle-form-table').click(function(event) {
|
43 |
-
$(this).wpcf7ToggleFormTable();
|
44 |
-
}).wpcf7ToggleFormTable();
|
45 |
-
|
46 |
-
if ('' == $('#title').val()) {
|
47 |
-
$('#title').focus();
|
48 |
}
|
49 |
|
50 |
$.wpcf7TitleHint();
|
51 |
|
52 |
-
$('.contact-form-editor-box-mail span.mailtag').click(function(event) {
|
53 |
var range = document.createRange();
|
54 |
-
range.selectNodeContents(this);
|
55 |
-
window.getSelection().addRange(range);
|
56 |
-
});
|
57 |
|
58 |
-
|
59 |
-
var section = $(this).attr('data-config-field');
|
60 |
-
|
61 |
-
if (_wpcf7.configErrors[section]) {
|
62 |
-
var $list = $('<ul></ul>').attr({
|
63 |
-
'role': 'alert',
|
64 |
-
'class': 'config-error'
|
65 |
-
});
|
66 |
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
'class': 'external'
|
74 |
-
}).text(_wpcf7.howToCorrectLink);
|
75 |
|
76 |
-
|
77 |
-
}
|
78 |
|
79 |
-
|
|
|
|
|
|
|
80 |
});
|
|
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
$(window).on('beforeunload', function(event) {
|
87 |
var changed = false;
|
88 |
|
89 |
-
$('#wpcf7-admin-form-element :input[type!="hidden"]').each(function() {
|
90 |
-
if ($(this).is(':checkbox, :radio')) {
|
91 |
-
if (this.defaultChecked != $(this).is(':checked')) {
|
92 |
changed = true;
|
93 |
}
|
94 |
-
} else if ($(this).is('select')) {
|
95 |
-
$(this).find('option').each(function() {
|
96 |
-
if (this.defaultSelected != $(this).is(':selected')) {
|
97 |
changed = true;
|
98 |
}
|
99 |
});
|
100 |
} else {
|
101 |
-
if (this.defaultValue != $(this).val()) {
|
102 |
changed = true;
|
103 |
}
|
104 |
}
|
105 |
-
});
|
106 |
|
107 |
-
if (changed) {
|
108 |
event.returnValue = _wpcf7.saveAlert;
|
109 |
return _wpcf7.saveAlert;
|
110 |
}
|
111 |
-
});
|
112 |
|
113 |
-
$('#wpcf7-admin-form-element').submit(function() {
|
114 |
-
if ('copy' != this.action.value) {
|
115 |
-
$(window).off('beforeunload');
|
116 |
}
|
117 |
|
118 |
-
if ('save' == this.action.value) {
|
119 |
-
$('#publishing-action .spinner').addClass('is-active');
|
120 |
}
|
121 |
-
});
|
122 |
-
});
|
123 |
|
124 |
$.fn.wpcf7ToggleFormTable = function() {
|
125 |
-
return this.each(function() {
|
126 |
-
var formtable = $(this).closest('.contact-form-editor-box-mail').find('fieldset');
|
127 |
|
128 |
-
if ($(this).is(':checked')) {
|
129 |
-
formtable.removeClass('hidden');
|
130 |
} else {
|
131 |
-
formtable.addClass('hidden');
|
132 |
}
|
133 |
-
});
|
134 |
};
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
/**
|
137 |
* Copied from wptitlehint() in wp-admin/js/post.js
|
138 |
*/
|
139 |
$.wpcf7TitleHint = function() {
|
140 |
-
var title = $('#title');
|
141 |
-
var titleprompt = $('#title-prompt-text');
|
142 |
|
143 |
-
if ('' == title.val()) {
|
144 |
-
titleprompt.removeClass('screen-reader-text');
|
145 |
}
|
146 |
|
147 |
-
titleprompt.click(function() {
|
148 |
-
$(this).addClass('screen-reader-text');
|
149 |
title.focus();
|
150 |
-
});
|
151 |
|
152 |
-
title.blur(function() {
|
153 |
-
if ('' == $(this).val()) {
|
154 |
-
titleprompt.removeClass('screen-reader-text');
|
155 |
}
|
156 |
-
}).focus(function() {
|
157 |
-
titleprompt.addClass('screen-reader-text');
|
158 |
-
}).keydown(function(e) {
|
159 |
-
titleprompt.addClass('screen-reader-text');
|
160 |
-
$(this).unbind(e);
|
161 |
-
});
|
162 |
};
|
163 |
|
164 |
-
})(jQuery);
|
1 |
+
( function( $ ) {
|
2 |
|
3 |
'use strict';
|
4 |
|
5 |
+
if ( typeof _wpcf7 === 'undefined' || _wpcf7 === null ) {
|
6 |
+
return;
|
7 |
}
|
8 |
|
9 |
+
$( function() {
|
10 |
+
var welcomePanel = $( '#welcome-panel' );
|
11 |
var updateWelcomePanel;
|
12 |
|
13 |
updateWelcomePanel = function( visible ) {
|
15 |
action: 'wpcf7-update-welcome-panel',
|
16 |
visible: visible,
|
17 |
welcomepanelnonce: $( '#welcomepanelnonce' ).val()
|
18 |
+
} );
|
19 |
};
|
20 |
|
21 |
+
$( 'a.welcome-panel-close', welcomePanel ).click( function( event ) {
|
22 |
event.preventDefault();
|
23 |
+
welcomePanel.addClass( 'hidden' );
|
24 |
updateWelcomePanel( 0 );
|
25 |
+
} );
|
26 |
|
27 |
+
$( '#contact-form-editor' ).tabs( {
|
28 |
active: _wpcf7.activeTab,
|
29 |
+
activate: function( event, ui ) {
|
30 |
+
$( '#active-tab' ).val( ui.newTab.index() );
|
31 |
}
|
32 |
+
} );
|
33 |
+
|
34 |
+
$( '#contact-form-editor-tabs' ).focusin( function( event ) {
|
35 |
+
$( '#contact-form-editor .keyboard-interaction' ).css(
|
36 |
+
'visibility', 'visible' );
|
37 |
+
} ).focusout( function( event ) {
|
38 |
+
$( '#contact-form-editor .keyboard-interaction' ).css(
|
39 |
+
'visibility', 'hidden' );
|
40 |
+
} );
|
41 |
+
|
42 |
+
$( 'input:checkbox.toggle-form-table' ).click( function( event ) {
|
43 |
+
$( this ).wpcf7ToggleFormTable();
|
44 |
+
} ).wpcf7ToggleFormTable();
|
45 |
+
|
46 |
+
if ( '' == $( '#title' ).val() ) {
|
47 |
+
$( '#title' ).focus();
|
48 |
}
|
49 |
|
50 |
$.wpcf7TitleHint();
|
51 |
|
52 |
+
$( '.contact-form-editor-box-mail span.mailtag' ).click( function( event ) {
|
53 |
var range = document.createRange();
|
54 |
+
range.selectNodeContents( this );
|
55 |
+
window.getSelection().addRange( range );
|
56 |
+
} );
|
57 |
|
58 |
+
$.wpcf7UpdateConfigErrors();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
$( '[data-config-field]' ).change( function() {
|
61 |
+
var postId = $( '#post_ID' ).val();
|
62 |
|
63 |
+
if ( ! postId || -1 == postId ) {
|
64 |
+
return;
|
65 |
+
}
|
|
|
|
|
66 |
|
67 |
+
var data = [];
|
|
|
68 |
|
69 |
+
$( this ).closest( 'form' ).find( '[data-config-field]' ).each( function() {
|
70 |
+
data.push( {
|
71 |
+
'name': $( this ).attr( 'name' ).replace( /^wpcf7-/, '' ).replace( /-/g, '_' ),
|
72 |
+
'value': $( this ).val()
|
73 |
});
|
74 |
+
});
|
75 |
|
76 |
+
data.push( { 'name': 'context', 'value': 'dry-run' } );
|
77 |
+
|
78 |
+
$.ajax( {
|
79 |
+
method: 'POST',
|
80 |
+
url: _wpcf7.apiSettings.root +
|
81 |
+
'contact-form-7/v1/contact-forms/' + postId,
|
82 |
+
beforeSend: function( xhr ) {
|
83 |
+
xhr.setRequestHeader( 'X-WP-Nonce', _wpcf7.apiSettings.nonce );
|
84 |
+
},
|
85 |
+
data: data
|
86 |
+
} ).done( function( response ) {
|
87 |
+
_wpcf7.configValidator.errors = response.config_errors;
|
88 |
+
$.wpcf7UpdateConfigErrors();
|
89 |
+
} );
|
90 |
+
} );
|
91 |
|
92 |
+
$( window ).on( 'beforeunload', function( event ) {
|
93 |
var changed = false;
|
94 |
|
95 |
+
$( '#wpcf7-admin-form-element :input[type!="hidden"]' ).each( function() {
|
96 |
+
if ( $( this ).is( ':checkbox, :radio' ) ) {
|
97 |
+
if ( this.defaultChecked != $( this ).is( ':checked' ) ) {
|
98 |
changed = true;
|
99 |
}
|
100 |
+
} else if ( $( this ).is( 'select' ) ) {
|
101 |
+
$( this ).find( 'option' ).each( function() {
|
102 |
+
if ( this.defaultSelected != $( this ).is( ':selected' ) ) {
|
103 |
changed = true;
|
104 |
}
|
105 |
});
|
106 |
} else {
|
107 |
+
if ( this.defaultValue != $( this ).val() ) {
|
108 |
changed = true;
|
109 |
}
|
110 |
}
|
111 |
+
} );
|
112 |
|
113 |
+
if ( changed ) {
|
114 |
event.returnValue = _wpcf7.saveAlert;
|
115 |
return _wpcf7.saveAlert;
|
116 |
}
|
117 |
+
} );
|
118 |
|
119 |
+
$( '#wpcf7-admin-form-element' ).submit( function() {
|
120 |
+
if ( 'copy' != this.action.value ) {
|
121 |
+
$( window ).off( 'beforeunload' );
|
122 |
}
|
123 |
|
124 |
+
if ( 'save' == this.action.value ) {
|
125 |
+
$( '#publishing-action .spinner' ).addClass( 'is-active' );
|
126 |
}
|
127 |
+
} );
|
128 |
+
} );
|
129 |
|
130 |
$.fn.wpcf7ToggleFormTable = function() {
|
131 |
+
return this.each( function() {
|
132 |
+
var formtable = $( this ).closest( '.contact-form-editor-box-mail' ).find( 'fieldset' );
|
133 |
|
134 |
+
if ( $( this ).is( ':checked' ) ) {
|
135 |
+
formtable.removeClass( 'hidden' );
|
136 |
} else {
|
137 |
+
formtable.addClass( 'hidden' );
|
138 |
}
|
139 |
+
} );
|
140 |
};
|
141 |
|
142 |
+
$.wpcf7UpdateConfigErrors = function() {
|
143 |
+
var errors = _wpcf7.configValidator.errors;
|
144 |
+
var errorCount = {
|
145 |
+
total: 0,
|
146 |
+
};
|
147 |
+
|
148 |
+
$( '[data-config-field]' ).each( function() {
|
149 |
+
$( this ).removeAttr( 'aria-invalid' );
|
150 |
+
$( this ).next( 'ul.config-error' ).remove();
|
151 |
+
|
152 |
+
var section = $( this ).attr( 'data-config-field' );
|
153 |
+
|
154 |
+
if ( errors[ section ] ) {
|
155 |
+
var $list = $( '<ul></ul>' ).attr( {
|
156 |
+
'role': 'alert',
|
157 |
+
'class': 'config-error'
|
158 |
+
} );
|
159 |
+
|
160 |
+
$.each( errors[ section ], function( i, val ) {
|
161 |
+
var $li = $( '<li></li>' ).text( val.message );
|
162 |
+
|
163 |
+
if ( val.link ) {
|
164 |
+
var $link = $( '<a></a>' ).attr( {
|
165 |
+
'href': val.link,
|
166 |
+
'class': 'external dashicons dashicons-external'
|
167 |
+
} ).append( $( '<span></span>' ).attr( {
|
168 |
+
'class': 'screen-reader-text'
|
169 |
+
} ).text( _wpcf7.configValidator.howToCorrect ) );
|
170 |
+
|
171 |
+
$li = $li.append( ' ' ).append( $link );
|
172 |
+
}
|
173 |
+
|
174 |
+
$li.appendTo( $list );
|
175 |
+
|
176 |
+
var tab = section
|
177 |
+
.replace( /^mail_\d+\./, 'mail.' ).replace( /\..*$/, '' );
|
178 |
+
|
179 |
+
if ( ! errorCount[tab] ) {
|
180 |
+
errorCount[tab] = 0;
|
181 |
+
}
|
182 |
+
|
183 |
+
errorCount[tab] += 1;
|
184 |
+
|
185 |
+
errorCount.total += 1;
|
186 |
+
} );
|
187 |
+
|
188 |
+
$( this ).after( $list ).attr( { 'aria-invalid': 'true' } );
|
189 |
+
}
|
190 |
+
} );
|
191 |
+
|
192 |
+
$( '#contact-form-editor-tabs > li' ).each( function() {
|
193 |
+
var $item = $( this );
|
194 |
+
$item.find( 'span.dashicons' ).remove();
|
195 |
+
var tab = $item.attr( 'id' ).replace( /-panel-tab$/, '' );
|
196 |
+
|
197 |
+
$.each( errors, function( key, val ) {
|
198 |
+
key = key.replace( /^mail_\d+\./, 'mail.' );
|
199 |
+
|
200 |
+
if ( key.replace( /\..*$/, '' ) == tab ) {
|
201 |
+
var $mark = $( '<span class="dashicons dashicons-warning"></span>' );
|
202 |
+
$item.find( 'a.ui-tabs-anchor' ).first().append( $mark );
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
} );
|
206 |
+
|
207 |
+
var $tabPanelError = $( '#' + tab + '-panel > div.config-error:first' );
|
208 |
+
$tabPanelError.empty();
|
209 |
+
|
210 |
+
if ( errorCount[tab] ) {
|
211 |
+
$tabPanelError
|
212 |
+
.append( '<span class="dashicons dashicons-warning"></span> ' );
|
213 |
+
|
214 |
+
if ( 1 < errorCount[tab] ) {
|
215 |
+
var manyErrorsInTab = _wpcf7.configValidator.manyErrorsInTab
|
216 |
+
.replace( '%d', errorCount[tab] );
|
217 |
+
$tabPanelError.append( manyErrorsInTab );
|
218 |
+
} else {
|
219 |
+
$tabPanelError.append( _wpcf7.configValidator.oneErrorInTab );
|
220 |
+
}
|
221 |
+
}
|
222 |
+
} );
|
223 |
+
|
224 |
+
$( '#misc-publishing-actions .misc-pub-section.config-error' )
|
225 |
+
.remove();
|
226 |
+
|
227 |
+
if ( errorCount.total ) {
|
228 |
+
var $warning = $( '<div></div>' )
|
229 |
+
.addClass( 'misc-pub-section config-error' )
|
230 |
+
.append( '<span class="dashicons dashicons-warning"></span> ' );
|
231 |
+
|
232 |
+
if ( 1 < errorCount.total ) {
|
233 |
+
$warning.append(
|
234 |
+
_wpcf7.configValidator.manyErrors.replace( '%d', errorCount.total )
|
235 |
+
);
|
236 |
+
} else {
|
237 |
+
$warning.append( _wpcf7.configValidator.oneError );
|
238 |
+
}
|
239 |
+
|
240 |
+
var $link = $( '<a></a>' ).attr( {
|
241 |
+
'href': _wpcf7.configValidator.docUrl,
|
242 |
+
'class': 'external dashicons dashicons-external'
|
243 |
+
} ).append( $( '<span></span>' ).attr( {
|
244 |
+
'class': 'screen-reader-text'
|
245 |
+
} ).text( _wpcf7.configValidator.howToCorrect ) );
|
246 |
+
|
247 |
+
$warning.append( ' ' ).append( $link );
|
248 |
+
|
249 |
+
$( '#misc-publishing-actions' ).append( $warning );
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
/**
|
254 |
* Copied from wptitlehint() in wp-admin/js/post.js
|
255 |
*/
|
256 |
$.wpcf7TitleHint = function() {
|
257 |
+
var title = $( '#title' );
|
258 |
+
var titleprompt = $( '#title-prompt-text' );
|
259 |
|
260 |
+
if ( '' == title.val() ) {
|
261 |
+
titleprompt.removeClass( 'screen-reader-text' );
|
262 |
}
|
263 |
|
264 |
+
titleprompt.click( function() {
|
265 |
+
$( this ).addClass( 'screen-reader-text' );
|
266 |
title.focus();
|
267 |
+
} );
|
268 |
|
269 |
+
title.blur( function() {
|
270 |
+
if ( '' == $(this).val() ) {
|
271 |
+
titleprompt.removeClass( 'screen-reader-text' );
|
272 |
}
|
273 |
+
} ).focus( function() {
|
274 |
+
titleprompt.addClass( 'screen-reader-text' );
|
275 |
+
} ).keydown( function( e ) {
|
276 |
+
titleprompt.addClass( 'screen-reader-text' );
|
277 |
+
$( this ).unbind( e );
|
278 |
+
} );
|
279 |
};
|
280 |
|
281 |
+
} )( jQuery );
|
admin/js/tag-generator.js
CHANGED
@@ -1,234 +1,240 @@
|
|
1 |
-
(function($) {
|
2 |
|
3 |
'use strict';
|
4 |
|
5 |
-
if (typeof _wpcf7
|
6 |
-
|
7 |
}
|
8 |
|
9 |
_wpcf7.taggen = {};
|
10 |
|
11 |
-
$(function() {
|
12 |
-
$('form.tag-generator-panel').each(function() {
|
13 |
-
_wpcf7.taggen.update($(this));
|
14 |
-
});
|
15 |
-
});
|
16 |
|
17 |
-
$('form.tag-generator-panel').submit(function(
|
18 |
return false;
|
19 |
-
});
|
20 |
-
|
21 |
-
$('form.tag-generator-panel .control-box :input').change(function(
|
22 |
-
var form = $(this).closest('form.tag-generator-panel');
|
23 |
-
_wpcf7.taggen.normalize($(this));
|
24 |
-
_wpcf7.taggen.update(form);
|
25 |
-
});
|
26 |
-
|
27 |
-
$('input.insert-tag').click(function(
|
28 |
-
var form = $(this).closest('form.tag-generator-panel');
|
29 |
-
var tag = form.find('input.tag').val();
|
30 |
-
_wpcf7.taggen.insert(tag);
|
31 |
tb_remove(); // close thickbox
|
32 |
return false;
|
33 |
-
});
|
34 |
|
35 |
-
_wpcf7.taggen.update = function($form) {
|
36 |
-
var id = $form.attr('data-id');
|
37 |
var name = '';
|
38 |
-
var name_fields = $form.find('input[name="name"]');
|
39 |
|
40 |
-
if (name_fields.length) {
|
41 |
name = name_fields.val();
|
42 |
|
43 |
-
if (''
|
44 |
-
name = id + '-' + Math.floor(Math.random() * 1000);
|
45 |
-
name_fields.val(name);
|
46 |
}
|
47 |
}
|
48 |
|
49 |
-
if ($.isFunction(_wpcf7.taggen.update[id])) {
|
50 |
-
return _wpcf7.taggen.update[id].call(this, $form);
|
51 |
}
|
52 |
|
53 |
-
$form.find('input.tag').each(function() {
|
54 |
-
var tag_type = $(this).attr('name');
|
55 |
|
56 |
-
if ($form.find(':input[name="tagtype"]').length) {
|
57 |
-
tag_type = $form.find(':input[name="tagtype"]').val();
|
58 |
}
|
59 |
|
60 |
-
if ($form.find(':input[name="required"]').is(':checked')) {
|
61 |
tag_type += '*';
|
62 |
}
|
63 |
|
64 |
-
var components = _wpcf7.taggen.compose(tag_type, $form);
|
65 |
-
$(this).val(components);
|
66 |
-
});
|
67 |
|
68 |
-
$form.find('span.mail-tag').text('[' + name + ']');
|
69 |
-
|
70 |
-
$form.find('input.mail-tag').each(function() {
|
71 |
-
$(this).val('[' + name + ']');
|
72 |
-
});
|
73 |
|
|
|
|
|
|
|
74 |
};
|
75 |
|
76 |
-
_wpcf7.taggen.update.captcha = function($form) {
|
77 |
-
var captchac = _wpcf7.taggen.compose('captchac', $form);
|
78 |
-
var captchar = _wpcf7.taggen.compose('captchar', $form);
|
79 |
|
80 |
-
$form.find('input.tag').val(captchac + ' ' + captchar);
|
81 |
};
|
82 |
|
83 |
-
_wpcf7.taggen.compose = function(tagType, $form) {
|
84 |
-
var name = $form.find('input[name="name"]').val();
|
85 |
-
var scope = $form.find('.scope.' + tagType);
|
86 |
|
87 |
-
if (! scope.length) {
|
88 |
scope = $form;
|
89 |
}
|
90 |
|
91 |
var options = [];
|
92 |
|
93 |
-
scope.find('input.option').not(':checkbox,:radio').each(function(i) {
|
94 |
-
var val = $(this).val();
|
95 |
|
96 |
-
if (! val) {
|
97 |
return;
|
98 |
}
|
99 |
|
100 |
-
if ($(this).hasClass('filetype')) {
|
101 |
-
val = val.split(/[,|\s]+/).join('|');
|
102 |
}
|
103 |
|
104 |
-
if ($(this).hasClass('color')) {
|
105 |
val = '#' + val;
|
106 |
}
|
107 |
|
108 |
-
if ('class' == $(this).attr('name')) {
|
109 |
-
$.each(val.split(' '), function(i, n) {
|
|
|
|
|
110 |
} else {
|
111 |
-
options.push($(this).attr('name') + ':' + val);
|
112 |
}
|
113 |
-
});
|
114 |
|
115 |
-
scope.find('input:checkbox.option').each(function(i) {
|
116 |
-
if ($(this).is(':checked')) {
|
117 |
-
options.push($(this).attr('name'));
|
118 |
}
|
119 |
-
});
|
120 |
|
121 |
-
scope.find('input:radio.option').each(function(i) {
|
122 |
-
if ($(this).is(':checked') && ! $(this).hasClass('default')) {
|
123 |
-
options.push($(this).attr('name') + ':' + $(this).val());
|
124 |
}
|
125 |
-
});
|
126 |
|
127 |
-
if ('radio' == tagType) {
|
128 |
-
options.push('default:1');
|
129 |
}
|
130 |
|
131 |
-
options = (options.length > 0) ? options.join(' ') : '';
|
132 |
|
133 |
var value = '';
|
134 |
|
135 |
-
if (scope.find(':input[name="values"]').val()) {
|
136 |
-
$.each(
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
139 |
}
|
140 |
|
141 |
var components = [];
|
142 |
|
143 |
-
$.each([tagType, name, options, value], function(i, v) {
|
144 |
-
v = $.trim(v);
|
145 |
|
146 |
-
if ('' != v) {
|
147 |
-
components.push(v);
|
148 |
}
|
149 |
-
});
|
150 |
|
151 |
-
components = $.trim(components.join(' '));
|
152 |
return '[' + components + ']';
|
153 |
-
}
|
154 |
|
155 |
-
_wpcf7.taggen.normalize = function($input) {
|
156 |
var val = $input.val();
|
157 |
|
158 |
-
if ($input.is('input[name="name"]')) {
|
159 |
-
val = val.replace(/[^0-9a-zA-Z:._-]/g, '').replace(/^[^a-zA-Z]+/, '');
|
160 |
}
|
161 |
|
162 |
-
if ($input.is('.numeric')) {
|
163 |
-
val = val.replace(/[^0-9.-]/g, '');
|
164 |
}
|
165 |
|
166 |
-
if ($input.is('.idvalue')) {
|
167 |
-
val = val.replace(/[^-0-9a-zA-Z_]/g, '');
|
168 |
}
|
169 |
|
170 |
-
if ($input.is('.classvalue')) {
|
171 |
-
val = $.map(val.split(' '), function(n) {
|
172 |
-
return n.replace(/[^-0-9a-zA-Z_]/g, '');
|
173 |
-
}).join(' ');
|
174 |
|
175 |
-
val = $.trim(val.replace(/\s+/g, ' '));
|
176 |
}
|
177 |
|
178 |
-
if ($input.is('.color')) {
|
179 |
-
val = val.replace(/[^0-9a-fA-F]/g, '');
|
180 |
}
|
181 |
|
182 |
-
if ($input.is('.filesize')) {
|
183 |
-
val = val.replace(/[^0-9kKmMbB]/g, '');
|
184 |
}
|
185 |
|
186 |
-
if ($input.is('.filetype')) {
|
187 |
-
val = val.replace(/[^0-9a-zA-Z.,|\s]/g, '');
|
188 |
}
|
189 |
|
190 |
-
if ($input.is('.date')) {
|
191 |
-
|
|
|
192 |
val = '';
|
193 |
}
|
194 |
}
|
195 |
|
196 |
-
if ($input.is(':input[name="values"]')) {
|
197 |
-
val = $.trim(val);
|
198 |
}
|
199 |
|
200 |
-
$input.val(val);
|
201 |
|
202 |
-
if ($input.is(':checkbox.exclusive')) {
|
203 |
-
_wpcf7.taggen.exclusiveCheckbox($input);
|
204 |
}
|
205 |
-
}
|
206 |
|
207 |
-
_wpcf7.taggen.exclusiveCheckbox = function($cb) {
|
208 |
-
if ($cb.is(':checked')) {
|
209 |
-
$cb.siblings(':checkbox.exclusive').prop('checked', false);
|
210 |
}
|
211 |
};
|
212 |
|
213 |
-
_wpcf7.taggen.insert = function(content) {
|
214 |
-
$('textarea#wpcf7-form').each(function() {
|
215 |
this.focus();
|
216 |
|
217 |
-
if (document.selection) { // IE
|
218 |
var selection = document.selection.createRange();
|
219 |
selection.text = content;
|
220 |
-
} else if (this.selectionEnd || 0 === this.selectionEnd) {
|
221 |
-
var val = $(this).val();
|
222 |
var end = this.selectionEnd;
|
223 |
-
$(this).val(val.substring(0, end) +
|
|
|
224 |
this.selectionStart = end + content.length;
|
225 |
this.selectionEnd = end + content.length;
|
226 |
} else {
|
227 |
-
$(this).val($(this).val() + content);
|
228 |
}
|
229 |
|
230 |
this.focus();
|
231 |
-
});
|
232 |
};
|
233 |
|
234 |
-
})(jQuery);
|
1 |
+
( function( $ ) {
|
2 |
|
3 |
'use strict';
|
4 |
|
5 |
+
if ( typeof _wpcf7 === 'undefined' || _wpcf7 === null ) {
|
6 |
+
return;
|
7 |
}
|
8 |
|
9 |
_wpcf7.taggen = {};
|
10 |
|
11 |
+
$( function() {
|
12 |
+
$( 'form.tag-generator-panel' ).each( function() {
|
13 |
+
_wpcf7.taggen.update( $( this ) );
|
14 |
+
} );
|
15 |
+
} );
|
16 |
|
17 |
+
$( 'form.tag-generator-panel' ).submit( function() {
|
18 |
return false;
|
19 |
+
} );
|
20 |
+
|
21 |
+
$( 'form.tag-generator-panel .control-box :input' ).change( function() {
|
22 |
+
var $form = $( this ).closest( 'form.tag-generator-panel' );
|
23 |
+
_wpcf7.taggen.normalize( $( this ) );
|
24 |
+
_wpcf7.taggen.update( $form );
|
25 |
+
} );
|
26 |
+
|
27 |
+
$( 'input.insert-tag' ).click( function() {
|
28 |
+
var $form = $( this ).closest( 'form.tag-generator-panel' );
|
29 |
+
var tag = $form.find( 'input.tag' ).val();
|
30 |
+
_wpcf7.taggen.insert( tag );
|
31 |
tb_remove(); // close thickbox
|
32 |
return false;
|
33 |
+
} );
|
34 |
|
35 |
+
_wpcf7.taggen.update = function( $form ) {
|
36 |
+
var id = $form.attr( 'data-id' );
|
37 |
var name = '';
|
38 |
+
var name_fields = $form.find( 'input[name="name"]' );
|
39 |
|
40 |
+
if ( name_fields.length ) {
|
41 |
name = name_fields.val();
|
42 |
|
43 |
+
if ( '' === name ) {
|
44 |
+
name = id + '-' + Math.floor( Math.random() * 1000 );
|
45 |
+
name_fields.val( name );
|
46 |
}
|
47 |
}
|
48 |
|
49 |
+
if ( $.isFunction( _wpcf7.taggen.update[ id ] ) ) {
|
50 |
+
return _wpcf7.taggen.update[ id ].call( this, $form );
|
51 |
}
|
52 |
|
53 |
+
$form.find( 'input.tag' ).each( function() {
|
54 |
+
var tag_type = $( this ).attr( 'name' );
|
55 |
|
56 |
+
if ( $form.find( ':input[name="tagtype"]' ).length ) {
|
57 |
+
tag_type = $form.find( ':input[name="tagtype"]' ).val();
|
58 |
}
|
59 |
|
60 |
+
if ( $form.find( ':input[name="required"]' ).is( ':checked' ) ) {
|
61 |
tag_type += '*';
|
62 |
}
|
63 |
|
64 |
+
var components = _wpcf7.taggen.compose( tag_type, $form );
|
65 |
+
$( this ).val( components );
|
66 |
+
} );
|
67 |
|
68 |
+
$form.find( 'span.mail-tag' ).text( '[' + name + ']' );
|
|
|
|
|
|
|
|
|
69 |
|
70 |
+
$form.find( 'input.mail-tag' ).each( function() {
|
71 |
+
$( this ).val( '[' + name + ']' );
|
72 |
+
} );
|
73 |
};
|
74 |
|
75 |
+
_wpcf7.taggen.update.captcha = function( $form ) {
|
76 |
+
var captchac = _wpcf7.taggen.compose( 'captchac', $form );
|
77 |
+
var captchar = _wpcf7.taggen.compose( 'captchar', $form );
|
78 |
|
79 |
+
$form.find( 'input.tag' ).val( captchac + ' ' + captchar );
|
80 |
};
|
81 |
|
82 |
+
_wpcf7.taggen.compose = function( tagType, $form ) {
|
83 |
+
var name = $form.find( 'input[name="name"]' ).val();
|
84 |
+
var scope = $form.find( '.scope.' + tagType );
|
85 |
|
86 |
+
if ( ! scope.length ) {
|
87 |
scope = $form;
|
88 |
}
|
89 |
|
90 |
var options = [];
|
91 |
|
92 |
+
scope.find( 'input.option' ).not( ':checkbox,:radio' ).each( function( i ) {
|
93 |
+
var val = $( this ).val();
|
94 |
|
95 |
+
if ( ! val ) {
|
96 |
return;
|
97 |
}
|
98 |
|
99 |
+
if ( $( this ).hasClass( 'filetype' ) ) {
|
100 |
+
val = val.split( /[,|\s]+/ ).join( '|' );
|
101 |
}
|
102 |
|
103 |
+
if ( $( this ).hasClass( 'color' ) ) {
|
104 |
val = '#' + val;
|
105 |
}
|
106 |
|
107 |
+
if ( 'class' == $( this ).attr( 'name' ) ) {
|
108 |
+
$.each( val.split( ' ' ), function( i, n ) {
|
109 |
+
options.push( 'class:' + n );
|
110 |
+
} );
|
111 |
} else {
|
112 |
+
options.push( $( this ).attr( 'name' ) + ':' + val );
|
113 |
}
|
114 |
+
} );
|
115 |
|
116 |
+
scope.find( 'input:checkbox.option' ).each( function( i ) {
|
117 |
+
if ( $( this ).is( ':checked' ) ) {
|
118 |
+
options.push( $( this ).attr( 'name' ) );
|
119 |
}
|
120 |
+
} );
|
121 |
|
122 |
+
scope.find( 'input:radio.option' ).each( function( i ) {
|
123 |
+
if ( $( this ).is( ':checked' ) && ! $( this ).hasClass( 'default' ) ) {
|
124 |
+
options.push( $( this ).attr( 'name' ) + ':' + $( this ).val() );
|
125 |
}
|
126 |
+
} );
|
127 |
|
128 |
+
if ( 'radio' == tagType ) {
|
129 |
+
options.push( 'default:1' );
|
130 |
}
|
131 |
|
132 |
+
options = ( options.length > 0 ) ? options.join( ' ' ) : '';
|
133 |
|
134 |
var value = '';
|
135 |
|
136 |
+
if ( scope.find( ':input[name="values"]' ).val() ) {
|
137 |
+
$.each(
|
138 |
+
scope.find( ':input[name="values"]' ).val().split( "\n" ),
|
139 |
+
function( i, n ) {
|
140 |
+
value += ' "' + n.replace( /["]/g, '"' ) + '"';
|
141 |
+
}
|
142 |
+
);
|
143 |
}
|
144 |
|
145 |
var components = [];
|
146 |
|
147 |
+
$.each( [ tagType, name, options, value ], function( i, v ) {
|
148 |
+
v = $.trim( v );
|
149 |
|
150 |
+
if ( '' != v ) {
|
151 |
+
components.push( v );
|
152 |
}
|
153 |
+
} );
|
154 |
|
155 |
+
components = $.trim( components.join( ' ' ) );
|
156 |
return '[' + components + ']';
|
157 |
+
};
|
158 |
|
159 |
+
_wpcf7.taggen.normalize = function( $input ) {
|
160 |
var val = $input.val();
|
161 |
|
162 |
+
if ( $input.is( 'input[name="name"]' ) ) {
|
163 |
+
val = val.replace( /[^0-9a-zA-Z:._-]/g, '' ).replace( /^[^a-zA-Z]+/, '' );
|
164 |
}
|
165 |
|
166 |
+
if ( $input.is( '.numeric' ) ) {
|
167 |
+
val = val.replace( /[^0-9.-]/g, '' );
|
168 |
}
|
169 |
|
170 |
+
if ( $input.is( '.idvalue' ) ) {
|
171 |
+
val = val.replace( /[^-0-9a-zA-Z_]/g, '' );
|
172 |
}
|
173 |
|
174 |
+
if ( $input.is( '.classvalue' ) ) {
|
175 |
+
val = $.map( val.split( ' ' ), function( n ) {
|
176 |
+
return n.replace( /[^-0-9a-zA-Z_]/g, '' );
|
177 |
+
} ).join( ' ' );
|
178 |
|
179 |
+
val = $.trim( val.replace( /\s+/g, ' ' ) );
|
180 |
}
|
181 |
|
182 |
+
if ( $input.is( '.color' ) ) {
|
183 |
+
val = val.replace( /[^0-9a-fA-F]/g, '' );
|
184 |
}
|
185 |
|
186 |
+
if ( $input.is( '.filesize' ) ) {
|
187 |
+
val = val.replace( /[^0-9kKmMbB]/g, '' );
|
188 |
}
|
189 |
|
190 |
+
if ( $input.is( '.filetype' ) ) {
|
191 |
+
val = val.replace( /[^0-9a-zA-Z.,|\s]/g, '' );
|
192 |
}
|
193 |
|
194 |
+
if ( $input.is( '.date' ) ) {
|
195 |
+
// 'yyyy-mm-dd' ISO 8601 format
|
196 |
+
if ( ! val.match( /^\d{4}-\d{2}-\d{2}$/ ) ) {
|
197 |
val = '';
|
198 |
}
|
199 |
}
|
200 |
|
201 |
+
if ( $input.is( ':input[name="values"]' ) ) {
|
202 |
+
val = $.trim( val );
|
203 |
}
|
204 |
|
205 |
+
$input.val( val );
|
206 |
|
207 |
+
if ( $input.is( ':checkbox.exclusive' ) ) {
|
208 |
+
_wpcf7.taggen.exclusiveCheckbox( $input );
|
209 |
}
|
210 |
+
};
|
211 |
|
212 |
+
_wpcf7.taggen.exclusiveCheckbox = function( $cb ) {
|
213 |
+
if ( $cb.is( ':checked' ) ) {
|
214 |
+
$cb.siblings( ':checkbox.exclusive' ).prop( 'checked', false );
|
215 |
}
|
216 |
};
|
217 |
|
218 |
+
_wpcf7.taggen.insert = function( content ) {
|
219 |
+
$( 'textarea#wpcf7-form' ).each( function() {
|
220 |
this.focus();
|
221 |
|
222 |
+
if ( document.selection ) { // IE
|
223 |
var selection = document.selection.createRange();
|
224 |
selection.text = content;
|
225 |
+
} else if ( this.selectionEnd || 0 === this.selectionEnd ) {
|
226 |
+
var val = $( this ).val();
|
227 |
var end = this.selectionEnd;
|
228 |
+
$( this ).val( val.substring( 0, end ) +
|
229 |
+
content + val.substring( end, val.length ) );
|
230 |
this.selectionStart = end + content.length;
|
231 |
this.selectionEnd = end + content.length;
|
232 |
} else {
|
233 |
+
$( this ).val( $( this ).val() + content );
|
234 |
}
|
235 |
|
236 |
this.focus();
|
237 |
+
} );
|
238 |
};
|
239 |
|
240 |
+
} )( jQuery );
|
includes/capabilities.php
CHANGED
@@ -8,7 +8,8 @@ function wpcf7_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
|
8 |
'wpcf7_edit_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
|
9 |
'wpcf7_read_contact_forms' => WPCF7_ADMIN_READ_CAPABILITY,
|
10 |
'wpcf7_delete_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
|
11 |
-
'wpcf7_manage_integration' => 'manage_options'
|
|
|
12 |
|
13 |
$meta_caps = apply_filters( 'wpcf7_map_meta_cap', $meta_caps );
|
14 |
|
8 |
'wpcf7_edit_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
|
9 |
'wpcf7_read_contact_forms' => WPCF7_ADMIN_READ_CAPABILITY,
|
10 |
'wpcf7_delete_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
|
11 |
+
'wpcf7_manage_integration' => 'manage_options',
|
12 |
+
);
|
13 |
|
14 |
$meta_caps = apply_filters( 'wpcf7_map_meta_cap', $meta_caps );
|
15 |
|
includes/config-validator.php
CHANGED
@@ -4,38 +4,32 @@ class WPCF7_ConfigValidator {
|
|
4 |
|
5 |
const error = 100;
|
6 |
const error_maybe_empty = 101;
|
7 |
-
const
|
8 |
const error_email_not_in_site_domain = 103;
|
9 |
const error_html_in_message = 104;
|
10 |
const error_multiple_controls_in_label = 105;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
private $contact_form;
|
13 |
private $errors = array();
|
14 |
|
15 |
public function __construct( WPCF7_ContactForm $contact_form ) {
|
16 |
$this->contact_form = $contact_form;
|
17 |
-
|
18 |
-
$config_errors = get_post_meta( $contact_form->id(),
|
19 |
-
'_config_errors', true );
|
20 |
-
|
21 |
-
foreach ( (array) $config_errors as $section => $errors ) {
|
22 |
-
if ( empty( $errors ) ) {
|
23 |
-
continue;
|
24 |
-
}
|
25 |
-
|
26 |
-
if ( ! is_array( $errors ) ) { // for back-compat
|
27 |
-
$code = $errors;
|
28 |
-
$this->add_error( $section, $code );
|
29 |
-
} else {
|
30 |
-
foreach ( (array) $errors as $error ) {
|
31 |
-
if ( ! empty( $error['code'] ) ) {
|
32 |
-
$code = $error['code'];
|
33 |
-
$args = isset( $error['args'] ) ? $error['args'] : '';
|
34 |
-
$this->add_error( $section, $code, $args );
|
35 |
-
}
|
36 |
-
}
|
37 |
-
}
|
38 |
-
}
|
39 |
}
|
40 |
|
41 |
public function contact_form() {
|
@@ -46,11 +40,36 @@ class WPCF7_ConfigValidator {
|
|
46 |
return ! $this->count_errors();
|
47 |
}
|
48 |
|
49 |
-
public function count_errors() {
|
|
|
|
|
|
|
|
|
|
|
50 |
$count = 0;
|
51 |
|
52 |
-
foreach( $this->errors as $errors ) {
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
return $count;
|
@@ -80,8 +99,8 @@ class WPCF7_ConfigValidator {
|
|
80 |
}
|
81 |
|
82 |
$error_messages[$section][] = array(
|
83 |
-
'message' => $message,
|
84 |
-
'link' => $link );
|
85 |
}
|
86 |
}
|
87 |
|
@@ -109,15 +128,17 @@ class WPCF7_ConfigValidator {
|
|
109 |
public function get_default_message( $code ) {
|
110 |
switch ( $code ) {
|
111 |
case self::error_maybe_empty:
|
112 |
-
return __( "
|
113 |
-
case self::
|
114 |
-
return __( "
|
115 |
case self::error_email_not_in_site_domain:
|
116 |
-
return __( "
|
117 |
case self::error_html_in_message:
|
118 |
-
return __( "HTML tags are
|
119 |
case self::error_multiple_controls_in_label:
|
120 |
-
return __( "Multiple form controls are
|
|
|
|
|
121 |
default:
|
122 |
return '';
|
123 |
}
|
@@ -126,13 +147,16 @@ class WPCF7_ConfigValidator {
|
|
126 |
public function add_error( $section, $code, $args = '' ) {
|
127 |
$args = wp_parse_args( $args, array(
|
128 |
'message' => '',
|
129 |
-
'params' => array()
|
|
|
130 |
|
131 |
if ( ! isset( $this->errors[$section] ) ) {
|
132 |
$this->errors[$section] = array();
|
133 |
}
|
134 |
|
135 |
$this->errors[$section][] = array( 'code' => $code, 'args' => $args );
|
|
|
|
|
136 |
}
|
137 |
|
138 |
public function remove_error( $section, $code ) {
|
@@ -157,11 +181,14 @@ class WPCF7_ConfigValidator {
|
|
157 |
|
158 |
do_action( 'wpcf7_config_validator_validate', $this );
|
159 |
|
160 |
-
$this->save();
|
161 |
return $this->is_valid();
|
162 |
}
|
163 |
|
164 |
public function save() {
|
|
|
|
|
|
|
|
|
165 |
delete_post_meta( $this->contact_form->id(), '_config_errors' );
|
166 |
|
167 |
if ( $this->errors ) {
|
@@ -170,21 +197,138 @@ class WPCF7_ConfigValidator {
|
|
170 |
}
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
public function validate_form() {
|
174 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
$pattern = '%<label(?:[ \t\n]+.*?)?>(.+?)</label>%s';
|
176 |
|
177 |
-
if ( preg_match_all( $pattern, $
|
178 |
-
$
|
179 |
|
180 |
foreach ( $matches[1] as $insidelabel ) {
|
181 |
-
$tags = $
|
182 |
$fields_count = 0;
|
183 |
|
184 |
foreach ( $tags as $tag ) {
|
185 |
$tag = new WPCF7_FormTag( $tag );
|
186 |
|
187 |
-
|
|
|
|
|
|
|
188 |
$fields_count += count( $tag->values );
|
189 |
|
190 |
if ( $tag->has_option( 'free_text' ) ) {
|
@@ -195,14 +339,53 @@ class WPCF7_ConfigValidator {
|
|
195 |
}
|
196 |
|
197 |
if ( 1 < $fields_count ) {
|
198 |
-
$this->add_error(
|
199 |
-
self::error_multiple_controls_in_label,
|
200 |
-
|
201 |
-
|
|
|
202 |
}
|
203 |
}
|
204 |
}
|
205 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
|
208 |
public function validate_mail( $template = 'mail' ) {
|
@@ -221,7 +404,9 @@ class WPCF7_ConfigValidator {
|
|
221 |
'sender' => '',
|
222 |
'recipient' => '',
|
223 |
'additional_headers' => '',
|
224 |
-
'body' => ''
|
|
|
|
|
225 |
|
226 |
$callback = array( $this, 'replace_mail_tags_with_minimum_input' );
|
227 |
|
@@ -230,12 +415,7 @@ class WPCF7_ConfigValidator {
|
|
230 |
array( 'callback' => $callback ) );
|
231 |
$subject = $subject->replace_tags();
|
232 |
$subject = wpcf7_strip_newline( $subject );
|
233 |
-
|
234 |
-
if ( '' === $subject ) {
|
235 |
-
$this->add_error( sprintf( '%s.subject', $template ),
|
236 |
-
self::error_maybe_empty,
|
237 |
-
array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.subject:error_maybe_empty', 'contact-form-7' ) ) );
|
238 |
-
}
|
239 |
|
240 |
$sender = $components['sender'];
|
241 |
$sender = new WPCF7_MailTaggedText( $sender,
|
@@ -243,14 +423,13 @@ class WPCF7_ConfigValidator {
|
|
243 |
$sender = $sender->replace_tags();
|
244 |
$sender = wpcf7_strip_newline( $sender );
|
245 |
|
246 |
-
if ( !
|
247 |
-
|
248 |
-
self::error_invalid_syntax,
|
249 |
-
array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.sender:error_invalid_syntax', 'contact-form-7' ) ) );
|
250 |
-
} elseif ( ! wpcf7_is_email_in_site_domain( $sender ) ) {
|
251 |
$this->add_error( sprintf( '%s.sender', $template ),
|
252 |
-
self::error_email_not_in_site_domain,
|
253 |
-
|
|
|
|
|
254 |
}
|
255 |
|
256 |
$recipient = $components['recipient'];
|
@@ -259,11 +438,8 @@ class WPCF7_ConfigValidator {
|
|
259 |
$recipient = $recipient->replace_tags();
|
260 |
$recipient = wpcf7_strip_newline( $recipient );
|
261 |
|
262 |
-
|
263 |
-
|
264 |
-
self::error_invalid_syntax,
|
265 |
-
array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.recipient:error_invalid_syntax', 'contact-form-7' ) ) );
|
266 |
-
}
|
267 |
|
268 |
$additional_headers = $components['additional_headers'];
|
269 |
$additional_headers = new WPCF7_MailTaggedText( $additional_headers,
|
@@ -271,6 +447,7 @@ class WPCF7_ConfigValidator {
|
|
271 |
$additional_headers = $additional_headers->replace_tags();
|
272 |
$additional_headers = explode( "\n", $additional_headers );
|
273 |
$mailbox_header_types = array( 'reply-to', 'cc', 'bcc' );
|
|
|
274 |
|
275 |
foreach ( $additional_headers as $header ) {
|
276 |
$header = trim( $header );
|
@@ -280,139 +457,125 @@ class WPCF7_ConfigValidator {
|
|
280 |
}
|
281 |
|
282 |
if ( ! preg_match( '/^([0-9A-Za-z-]+):(.+)$/', $header, $matches ) ) {
|
283 |
-
$
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
'
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
|
|
294 |
}
|
295 |
}
|
296 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
$body = $components['body'];
|
298 |
$body = new WPCF7_MailTaggedText( $body,
|
299 |
array( 'callback' => $callback ) );
|
300 |
$body = $body->replace_tags();
|
|
|
301 |
|
302 |
-
if ( ''
|
303 |
-
|
304 |
-
|
305 |
-
array( 'link' => __( 'http://contactform7.com/configuration-errors/#mail.body:error_maybe_empty', 'contact-form-7' ) ) );
|
306 |
-
}
|
307 |
-
}
|
308 |
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
if ( ! $messages ) {
|
313 |
-
return;
|
314 |
-
}
|
315 |
-
|
316 |
-
if ( isset( $messages['captcha_not_match'] )
|
317 |
-
&& ! wpcf7_use_really_simple_captcha() ) {
|
318 |
-
unset( $messages['captcha_not_match'] );
|
319 |
-
}
|
320 |
-
|
321 |
-
foreach ( $messages as $key => $message ) {
|
322 |
-
$stripped = wp_strip_all_tags( $message );
|
323 |
|
324 |
-
|
325 |
-
|
326 |
-
self::error_html_in_message,
|
327 |
-
array( 'link' => __( 'http://contactform7.com/configuration-errors/#messages:error_html_in_message', 'contact-form-7' ) ) );
|
328 |
}
|
329 |
}
|
330 |
}
|
331 |
|
332 |
-
public function
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
$tag = $matches[0];
|
339 |
-
$tagname = $matches[2];
|
340 |
-
$values = $matches[3];
|
341 |
|
342 |
-
if ( !
|
343 |
-
|
344 |
-
|
345 |
}
|
346 |
|
347 |
-
|
|
|
348 |
|
349 |
-
|
350 |
-
|
351 |
-
$
|
|
|
|
|
|
|
|
|
352 |
}
|
353 |
|
354 |
-
|
|
|
355 |
|
356 |
-
|
357 |
-
|
358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
}
|
360 |
|
361 |
-
|
362 |
-
|
363 |
-
$example_blank = '';
|
364 |
-
|
365 |
-
$form_tags = $this->contact_form->scan_form_tags(
|
366 |
-
array( 'name' => $tagname ) );
|
367 |
-
|
368 |
-
if ( $form_tags ) {
|
369 |
-
$form_tag = new WPCF7_FormTag( $form_tags[0] );
|
370 |
-
|
371 |
-
$is_required = ( $form_tag->is_required() || 'radio' == $form_tag->type );
|
372 |
-
|
373 |
-
if ( ! $is_required ) {
|
374 |
-
return $example_blank;
|
375 |
-
}
|
376 |
|
377 |
-
|
378 |
-
|
379 |
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
$before_pipes = $form_tag->pipes->collect_befores();
|
384 |
-
$last_item = array_pop( $before_pipes );
|
385 |
-
} else {
|
386 |
-
$after_pipes = $form_tag->pipes->collect_afters();
|
387 |
-
$last_item = array_pop( $after_pipes );
|
388 |
-
}
|
389 |
-
} else {
|
390 |
-
$last_item = array_pop( $form_tag->values );
|
391 |
-
}
|
392 |
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
}
|
398 |
-
}
|
399 |
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
|
406 |
-
|
407 |
-
|
408 |
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
|
|
|
|
414 |
}
|
415 |
|
416 |
-
return
|
417 |
}
|
418 |
}
|
4 |
|
5 |
const error = 100;
|
6 |
const error_maybe_empty = 101;
|
7 |
+
const error_invalid_mailbox_syntax = 102;
|
8 |
const error_email_not_in_site_domain = 103;
|
9 |
const error_html_in_message = 104;
|
10 |
const error_multiple_controls_in_label = 105;
|
11 |
+
const error_file_not_found = 106;
|
12 |
+
const error_unavailable_names = 107;
|
13 |
+
const error_invalid_mail_header = 108;
|
14 |
+
|
15 |
+
public static function get_doc_link( $error_code = '' ) {
|
16 |
+
$url = __( 'https://contactform7.com/configuration-errors/',
|
17 |
+
'contact-form-7' );
|
18 |
+
|
19 |
+
if ( '' !== $error_code ) {
|
20 |
+
$error_code = strtr( $error_code, '_', '-' );
|
21 |
+
|
22 |
+
$url = sprintf( '%s/%s', untrailingslashit( $url ), $error_code );
|
23 |
+
}
|
24 |
+
|
25 |
+
return esc_url( $url );
|
26 |
+
}
|
27 |
|
28 |
private $contact_form;
|
29 |
private $errors = array();
|
30 |
|
31 |
public function __construct( WPCF7_ContactForm $contact_form ) {
|
32 |
$this->contact_form = $contact_form;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
public function contact_form() {
|
40 |
return ! $this->count_errors();
|
41 |
}
|
42 |
|
43 |
+
public function count_errors( $args = '' ) {
|
44 |
+
$args = wp_parse_args( $args, array(
|
45 |
+
'section' => '',
|
46 |
+
'code' => '',
|
47 |
+
) );
|
48 |
+
|
49 |
$count = 0;
|
50 |
|
51 |
+
foreach ( $this->errors as $key => $errors ) {
|
52 |
+
if ( preg_match( '/^mail_[0-9]+\.(.*)$/', $key, $matches ) ) {
|
53 |
+
$key = sprintf( 'mail.%s', $matches[1] );
|
54 |
+
}
|
55 |
+
|
56 |
+
if ( $args['section']
|
57 |
+
&& $key != $args['section']
|
58 |
+
&& preg_replace( '/\..*$/', '', $key, 1 ) != $args['section'] ) {
|
59 |
+
continue;
|
60 |
+
}
|
61 |
+
|
62 |
+
foreach ( $errors as $error ) {
|
63 |
+
if ( empty( $error ) ) {
|
64 |
+
continue;
|
65 |
+
}
|
66 |
+
|
67 |
+
if ( $args['code'] && $error['code'] != $args['code'] ) {
|
68 |
+
continue;
|
69 |
+
}
|
70 |
+
|
71 |
+
$count += 1;
|
72 |
+
}
|
73 |
}
|
74 |
|
75 |
return $count;
|
99 |
}
|
100 |
|
101 |
$error_messages[$section][] = array(
|
102 |
+
'message' => esc_html( $message ),
|
103 |
+
'link' => esc_url( $link ) );
|
104 |
}
|
105 |
}
|
106 |
|
128 |
public function get_default_message( $code ) {
|
129 |
switch ( $code ) {
|
130 |
case self::error_maybe_empty:
|
131 |
+
return __( "There is a possible empty field.", 'contact-form-7' );
|
132 |
+
case self::error_invalid_mailbox_syntax:
|
133 |
+
return __( "Invalid mailbox syntax is used.", 'contact-form-7' );
|
134 |
case self::error_email_not_in_site_domain:
|
135 |
+
return __( "Sender email address does not belong to the site domain.", 'contact-form-7' );
|
136 |
case self::error_html_in_message:
|
137 |
+
return __( "HTML tags are used in a message.", 'contact-form-7' );
|
138 |
case self::error_multiple_controls_in_label:
|
139 |
+
return __( "Multiple form controls are in a single label element.", 'contact-form-7' );
|
140 |
+
case self::error_invalid_mail_header:
|
141 |
+
return __( "There are invalid mail header fields.", 'contact-form-7' );
|
142 |
default:
|
143 |
return '';
|
144 |
}
|
147 |
public function add_error( $section, $code, $args = '' ) {
|
148 |
$args = wp_parse_args( $args, array(
|
149 |
'message' => '',
|
150 |
+
'params' => array(),
|
151 |
+
) );
|
152 |
|
153 |
if ( ! isset( $this->errors[$section] ) ) {
|
154 |
$this->errors[$section] = array();
|
155 |
}
|
156 |
|
157 |
$this->errors[$section][] = array( 'code' => $code, 'args' => $args );
|
158 |
+
|
159 |
+
return true;
|
160 |
}
|
161 |
|
162 |
public function remove_error( $section, $code ) {
|
181 |
|
182 |
do_action( 'wpcf7_config_validator_validate', $this );
|
183 |
|
|
|
184 |
return $this->is_valid();
|
185 |
}
|
186 |
|
187 |
public function save() {
|
188 |
+
if ( $this->contact_form->initial() ) {
|
189 |
+
return;
|
190 |
+
}
|
191 |
+
|
192 |
delete_post_meta( $this->contact_form->id(), '_config_errors' );
|
193 |
|
194 |
if ( $this->errors ) {
|
197 |
}
|
198 |
}
|
199 |
|
200 |
+
public function restore() {
|
201 |
+
$config_errors = get_post_meta(
|
202 |
+
$this->contact_form->id(), '_config_errors', true );
|
203 |
+
|
204 |
+
foreach ( (array) $config_errors as $section => $errors ) {
|
205 |
+
if ( empty( $errors ) ) {
|
206 |
+
continue;
|
207 |
+
}
|
208 |
+
|
209 |
+
if ( ! is_array( $errors ) ) { // for back-compat
|
210 |
+
$code = $errors;
|
211 |
+
$this->add_error( $section, $code );
|
212 |
+
} else {
|
213 |
+
foreach ( (array) $errors as $error ) {
|
214 |
+
if ( ! empty( $error['code'] ) ) {
|
215 |
+
$code = $error['code'];
|
216 |
+
$args = isset( $error['args'] ) ? $error['args'] : '';
|
217 |
+
$this->add_error( $section, $code, $args );
|
218 |
+
}
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
public function replace_mail_tags_with_minimum_input( $matches ) {
|
225 |
+
// allow [[foo]] syntax for escaping a tag
|
226 |
+
if ( $matches[1] == '[' && $matches[4] == ']' ) {
|
227 |
+
return substr( $matches[0], 1, -1 );
|
228 |
+
}
|
229 |
+
|
230 |
+
$tag = $matches[0];
|
231 |
+
$tagname = $matches[2];
|
232 |
+
$values = $matches[3];
|
233 |
+
|
234 |
+
if ( ! empty( $values ) ) {
|
235 |
+
preg_match_all( '/"[^"]*"|\'[^\']*\'/', $values, $matches );
|
236 |
+
$values = wpcf7_strip_quote_deep( $matches[0] );
|
237 |
+
}
|
238 |
+
|
239 |
+
$do_not_heat = false;
|
240 |
+
|
241 |
+
if ( preg_match( '/^_raw_(.+)$/', $tagname, $matches ) ) {
|
242 |
+
$tagname = trim( $matches[1] );
|
243 |
+
$do_not_heat = true;
|
244 |
+
}
|
245 |
+
|
246 |
+
$format = '';
|
247 |
+
|
248 |
+
if ( preg_match( '/^_format_(.+)$/', $tagname, $matches ) ) {
|
249 |
+
$tagname = trim( $matches[1] );
|
250 |
+
$format = $values[0];
|
251 |
+
}
|
252 |
+
|
253 |
+
$example_email = 'example@example.com';
|
254 |
+
$example_text = 'example';
|
255 |
+
$example_blank = '';
|
256 |
+
|
257 |
+
$form_tags = $this->contact_form->scan_form_tags(
|
258 |
+
array( 'name' => $tagname ) );
|
259 |
+
|
260 |
+
if ( $form_tags ) {
|
261 |
+
$form_tag = new WPCF7_FormTag( $form_tags[0] );
|
262 |
+
|
263 |
+
$is_required = ( $form_tag->is_required() || 'radio' == $form_tag->type );
|
264 |
+
|
265 |
+
if ( ! $is_required ) {
|
266 |
+
return $example_blank;
|
267 |
+
}
|
268 |
+
|
269 |
+
if ( wpcf7_form_tag_supports( $form_tag->type, 'selectable-values' ) ) {
|
270 |
+
if ( $form_tag->pipes instanceof WPCF7_Pipes ) {
|
271 |
+
if ( $do_not_heat ) {
|
272 |
+
$before_pipes = $form_tag->pipes->collect_befores();
|
273 |
+
$last_item = array_pop( $before_pipes );
|
274 |
+
} else {
|
275 |
+
$after_pipes = $form_tag->pipes->collect_afters();
|
276 |
+
$last_item = array_pop( $after_pipes );
|
277 |
+
}
|
278 |
+
} else {
|
279 |
+
$last_item = array_pop( $form_tag->values );
|
280 |
+
}
|
281 |
+
|
282 |
+
if ( $last_item && wpcf7_is_mailbox_list( $last_item ) ) {
|
283 |
+
return $example_email;
|
284 |
+
} else {
|
285 |
+
return $example_text;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
if ( 'email' == $form_tag->basetype ) {
|
290 |
+
return $example_email;
|
291 |
+
} else {
|
292 |
+
return $example_text;
|
293 |
+
}
|
294 |
+
|
295 |
+
} else {
|
296 |
+
$tagname = preg_replace( '/^wpcf7\./', '_', $tagname ); // for back-compat
|
297 |
+
|
298 |
+
if ( '_post_author_email' == $tagname ) {
|
299 |
+
return $example_email;
|
300 |
+
} elseif ( '_' == substr( $tagname, 0, 1 ) ) { // maybe special mail tag
|
301 |
+
return $example_text;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
return $tag;
|
306 |
+
}
|
307 |
+
|
308 |
public function validate_form() {
|
309 |
+
$section = 'form.body';
|
310 |
+
$form = $this->contact_form->prop( 'form' );
|
311 |
+
$this->detect_multiple_controls_in_label( $section, $form );
|
312 |
+
$this->detect_unavailable_names( $section, $form );
|
313 |
+
}
|
314 |
+
|
315 |
+
public function detect_multiple_controls_in_label( $section, $content ) {
|
316 |
$pattern = '%<label(?:[ \t\n]+.*?)?>(.+?)</label>%s';
|
317 |
|
318 |
+
if ( preg_match_all( $pattern, $content, $matches ) ) {
|
319 |
+
$form_tags_manager = WPCF7_FormTagsManager::get_instance();
|
320 |
|
321 |
foreach ( $matches[1] as $insidelabel ) {
|
322 |
+
$tags = $form_tags_manager->scan( $insidelabel );
|
323 |
$fields_count = 0;
|
324 |
|
325 |
foreach ( $tags as $tag ) {
|
326 |
$tag = new WPCF7_FormTag( $tag );
|
327 |
|
328 |
+
$is_multiple_controls_container = wpcf7_form_tag_supports(
|
329 |
+
$tag->type, 'multiple-controls-container' );
|
330 |
+
|
331 |
+
if ( $is_multiple_controls_container ) {
|
332 |
$fields_count += count( $tag->values );
|
333 |
|
334 |
if ( $tag->has_option( 'free_text' ) ) {
|
339 |
}
|
340 |
|
341 |
if ( 1 < $fields_count ) {
|
342 |
+
return $this->add_error( $section,
|
343 |
+
self::error_multiple_controls_in_label, array(
|
344 |
+
'link' => self::get_doc_link( 'multiple_controls_in_label' ),
|
345 |
+
)
|
346 |
+
);
|
347 |
}
|
348 |
}
|
349 |
}
|
350 |
}
|
351 |
+
|
352 |
+
return false;
|
353 |
+
}
|
354 |
+
|
355 |
+
public function detect_unavailable_names( $section, $content ) {
|
356 |
+
$public_query_vars = array( 'm', 'p', 'posts', 'w', 'cat',
|
357 |
+
'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence',
|
358 |
+
'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order',
|
359 |
+
'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second',
|
360 |
+
'name', 'category_name', 'tag', 'feed', 'author_name', 'static',
|
361 |
+
'pagename', 'page_id', 'error', 'attachment', 'attachment_id',
|
362 |
+
'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term',
|
363 |
+
'cpage', 'post_type', 'embed' );
|
364 |
+
|
365 |
+
$form_tags_manager = WPCF7_FormTagsManager::get_instance();
|
366 |
+
$ng_named_tags = $form_tags_manager->filter( $content,
|
367 |
+
array( 'name' => $public_query_vars ) );
|
368 |
+
|
369 |
+
$ng_names = array();
|
370 |
+
|
371 |
+
foreach ( $ng_named_tags as $tag ) {
|
372 |
+
$ng_names[] = $tag['name'];
|
373 |
+
}
|
374 |
+
|
375 |
+
if ( $ng_names ) {
|
376 |
+
$ng_names = array_unique( $ng_names );
|
377 |
+
|
378 |
+
return $this->add_error( $section,
|
379 |
+
self::error_unavailable_names,
|
380 |
+
array(
|
381 |
+
'message' => __( "Unavailable names (%names%) are used for form controls.", 'contact-form-7' ),
|
382 |
+
'params' => array( 'names' => implode( ', ', $ng_names ) ),
|
383 |
+
'link' => self::get_doc_link( 'unavailable_names' ),
|
384 |
+
)
|
385 |
+
);
|
386 |
+
}
|
387 |
+
|
388 |
+
return false;
|
389 |
}
|
390 |
|
391 |
public function validate_mail( $template = 'mail' ) {
|
404 |
'sender' => '',
|
405 |
'recipient' => '',
|
406 |
'additional_headers' => '',
|
407 |
+
'body' => '',
|
408 |
+
'attachments' => '',
|
409 |
+
) );
|
410 |
|
411 |
$callback = array( $this, 'replace_mail_tags_with_minimum_input' );
|
412 |
|
415 |
array( 'callback' => $callback ) );
|
416 |
$subject = $subject->replace_tags();
|
417 |
$subject = wpcf7_strip_newline( $subject );
|
418 |
+
$this->detect_maybe_empty( sprintf( '%s.subject', $template ), $subject );
|
|
|
|
|
|
|
|
|
|
|
419 |
|
420 |
$sender = $components['sender'];
|
421 |
$sender = new WPCF7_MailTaggedText( $sender,
|
423 |
$sender = $sender->replace_tags();
|
424 |
$sender = wpcf7_strip_newline( $sender );
|
425 |
|
426 |
+
if ( ! $this->detect_invalid_mailbox_syntax( sprintf( '%s.sender', $template ), $sender )
|
427 |
+
&& ! wpcf7_is_email_in_site_domain( $sender ) ) {
|
|
|
|
|
|
|
428 |
$this->add_error( sprintf( '%s.sender', $template ),
|
429 |
+
self::error_email_not_in_site_domain, array(
|
430 |
+
'link' => self::get_doc_link( 'email_not_in_site_domain' ),
|
431 |
+
)
|
432 |
+
);
|
433 |
}
|
434 |
|
435 |
$recipient = $components['recipient'];
|
438 |
$recipient = $recipient->replace_tags();
|
439 |
$recipient = wpcf7_strip_newline( $recipient );
|
440 |
|
441 |
+
$this->detect_invalid_mailbox_syntax(
|
442 |
+
sprintf( '%s.recipient', $template ), $recipient );
|
|
|
|
|
|
|
443 |
|
444 |
$additional_headers = $components['additional_headers'];
|
445 |
$additional_headers = new WPCF7_MailTaggedText( $additional_headers,
|
447 |
$additional_headers = $additional_headers->replace_tags();
|
448 |
$additional_headers = explode( "\n", $additional_headers );
|
449 |
$mailbox_header_types = array( 'reply-to', 'cc', 'bcc' );
|
450 |
+
$invalid_mail_header_exists = false;
|
451 |
|
452 |
foreach ( $additional_headers as $header ) {
|
453 |
$header = trim( $header );
|
457 |
}
|
458 |
|
459 |
if ( ! preg_match( '/^([0-9A-Za-z-]+):(.+)$/', $header, $matches ) ) {
|
460 |
+
$invalid_mail_header_exists = true;
|
461 |
+
} else {
|
462 |
+
$header_name = $matches[1];
|
463 |
+
$header_value = $matches[2];
|
464 |
+
|
465 |
+
if ( in_array( strtolower( $header_name ), $mailbox_header_types ) ) {
|
466 |
+
$this->detect_invalid_mailbox_syntax(
|
467 |
+
sprintf( '%s.additional_headers', $template ),
|
468 |
+
$header_value, array(
|
469 |
+
'message' =>
|
470 |
+
__( "Invalid mailbox syntax is used in the %name% field.", 'contact-form-7' ),
|
471 |
+
'params' => array( 'name' => $header_name ) ) );
|
472 |
+
}
|
473 |
}
|
474 |
}
|
475 |
|
476 |
+
if ( $invalid_mail_header_exists ) {
|
477 |
+
$this->add_error( sprintf( '%s.additional_headers', $template ),
|
478 |
+
self::error_invalid_mail_header, array(
|
479 |
+
'link' => self::get_doc_link( 'invalid_mail_header' ),
|
480 |
+
)
|
481 |
+
);
|
482 |
+
}
|
483 |
+
|
484 |
$body = $components['body'];
|
485 |
$body = new WPCF7_MailTaggedText( $body,
|
486 |
array( 'callback' => $callback ) );
|
487 |
$body = $body->replace_tags();
|
488 |
+
$this->detect_maybe_empty( sprintf( '%s.body', $template ), $body );
|
489 |
|
490 |
+
if ( '' !== $components['attachments'] ) {
|
491 |
+
foreach ( explode( "\n", $components['attachments'] ) as $line ) {
|
492 |
+
$line = trim( $line );
|
|
|
|
|
|
|
493 |
|
494 |
+
if ( '' === $line || '[' == substr( $line, 0, 1 ) ) {
|
495 |
+
continue;
|
496 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
|
498 |
+
$this->detect_file_not_found(
|
499 |
+
sprintf( '%s.attachments', $template ), $line );
|
|
|
|
|
500 |
}
|
501 |
}
|
502 |
}
|
503 |
|
504 |
+
public function detect_invalid_mailbox_syntax( $section, $content, $args = '' ) {
|
505 |
+
$args = wp_parse_args( $args, array(
|
506 |
+
'link' => self::get_doc_link( 'invalid_mailbox_syntax' ),
|
507 |
+
'message' => '',
|
508 |
+
'params' => array(),
|
509 |
+
) );
|
|
|
|
|
|
|
510 |
|
511 |
+
if ( ! wpcf7_is_mailbox_list( $content ) ) {
|
512 |
+
return $this->add_error( $section,
|
513 |
+
self::error_invalid_mailbox_syntax, $args );
|
514 |
}
|
515 |
|
516 |
+
return false;
|
517 |
+
}
|
518 |
|
519 |
+
public function detect_maybe_empty( $section, $content ) {
|
520 |
+
if ( '' === $content ) {
|
521 |
+
return $this->add_error( $section,
|
522 |
+
self::error_maybe_empty, array(
|
523 |
+
'link' => self::get_doc_link( 'maybe_empty' ),
|
524 |
+
)
|
525 |
+
);
|
526 |
}
|
527 |
|
528 |
+
return false;
|
529 |
+
}
|
530 |
|
531 |
+
public function detect_file_not_found( $section, $content ) {
|
532 |
+
$path = path_join( WP_CONTENT_DIR, $content );
|
533 |
+
|
534 |
+
if ( ! @is_readable( $path ) || ! @is_file( $path ) ) {
|
535 |
+
return $this->add_error( $section,
|
536 |
+
self::error_file_not_found,
|
537 |
+
array(
|
538 |
+
'message' =>
|
539 |
+
__( "Attachment file does not exist at %path%.", 'contact-form-7' ),
|
540 |
+
'params' => array( 'path' => $content ),
|
541 |
+
'link' => self::get_doc_link( 'file_not_found' ),
|
542 |
+
)
|
543 |
+
);
|
544 |
}
|
545 |
|
546 |
+
return false;
|
547 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
548 |
|
549 |
+
public function validate_messages() {
|
550 |
+
$messages = (array) $this->contact_form->prop( 'messages' );
|
551 |
|
552 |
+
if ( ! $messages ) {
|
553 |
+
return;
|
554 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
|
556 |
+
if ( isset( $messages['captcha_not_match'] )
|
557 |
+
&& ! wpcf7_use_really_simple_captcha() ) {
|
558 |
+
unset( $messages['captcha_not_match'] );
|
559 |
+
}
|
|
|
|
|
560 |
|
561 |
+
foreach ( $messages as $key => $message ) {
|
562 |
+
$section = sprintf( 'messages.%s', $key );
|
563 |
+
$this->detect_html_in_message( $section, $message );
|
564 |
+
}
|
565 |
+
}
|
566 |
|
567 |
+
public function detect_html_in_message( $section, $content ) {
|
568 |
+
$stripped = wp_strip_all_tags( $content );
|
569 |
|
570 |
+
if ( $stripped != $content ) {
|
571 |
+
return $this->add_error( $section,
|
572 |
+
self::error_html_in_message,
|
573 |
+
array(
|
574 |
+
'link' => self::get_doc_link( 'html_in_message' ),
|
575 |
+
)
|
576 |
+
);
|
577 |
}
|
578 |
|
579 |
+
return false;
|
580 |
}
|
581 |
}
|
includes/contact-form-functions.php
ADDED
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wpcf7_contact_form( $id ) {
|
4 |
+
return WPCF7_ContactForm::get_instance( $id );
|
5 |
+
}
|
6 |
+
|
7 |
+
function wpcf7_get_contact_form_by_old_id( $old_id ) {
|
8 |
+
global $wpdb;
|
9 |
+
|
10 |
+
$q = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_old_cf7_unit_id'"
|
11 |
+
. $wpdb->prepare( " AND meta_value = %d", $old_id );
|
12 |
+
|
13 |
+
if ( $new_id = $wpdb->get_var( $q ) ) {
|
14 |
+
return wpcf7_contact_form( $new_id );
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
function wpcf7_get_contact_form_by_title( $title ) {
|
19 |
+
$page = get_page_by_title( $title, OBJECT, WPCF7_ContactForm::post_type );
|
20 |
+
|
21 |
+
if ( $page ) {
|
22 |
+
return wpcf7_contact_form( $page->ID );
|
23 |
+
}
|
24 |
+
|
25 |
+
return null;
|
26 |
+
}
|
27 |
+
|
28 |
+
function wpcf7_get_current_contact_form() {
|
29 |
+
if ( $current = WPCF7_ContactForm::get_current() ) {
|
30 |
+
return $current;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
function wpcf7_is_posted() {
|
35 |
+
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
|
39 |
+
return $contact_form->is_posted();
|
40 |
+
}
|
41 |
+
|
42 |
+
function wpcf7_get_hangover( $name, $default = null ) {
|
43 |
+
if ( ! wpcf7_is_posted() ) {
|
44 |
+
return $default;
|
45 |
+
}
|
46 |
+
|
47 |
+
$submission = WPCF7_Submission::get_instance();
|
48 |
+
|
49 |
+
if ( ! $submission || $submission->is( 'mail_sent' ) ) {
|
50 |
+
return $default;
|
51 |
+
}
|
52 |
+
|
53 |
+
return isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : $default;
|
54 |
+
}
|
55 |
+
|
56 |
+
function wpcf7_get_validation_error( $name ) {
|
57 |
+
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
58 |
+
return '';
|
59 |
+
}
|
60 |
+
|
61 |
+
return $contact_form->validation_error( $name );
|
62 |
+
}
|
63 |
+
|
64 |
+
function wpcf7_get_message( $status ) {
|
65 |
+
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
66 |
+
return '';
|
67 |
+
}
|
68 |
+
|
69 |
+
return $contact_form->message( $status );
|
70 |
+
}
|
71 |
+
|
72 |
+
function wpcf7_form_controls_class( $type, $default = '' ) {
|
73 |
+
$type = trim( $type );
|
74 |
+
$default = array_filter( explode( ' ', $default ) );
|
75 |
+
|
76 |
+
$classes = array_merge( array( 'wpcf7-form-control' ), $default );
|
77 |
+
|
78 |
+
$typebase = rtrim( $type, '*' );
|
79 |
+
$required = ( '*' == substr( $type, -1 ) );
|
80 |
+
|
81 |
+
$classes[] = 'wpcf7-' . $typebase;
|
82 |
+
|
83 |
+
if ( $required ) {
|
84 |
+
$classes[] = 'wpcf7-validates-as-required';
|
85 |
+
}
|
86 |
+
|
87 |
+
$classes = array_unique( $classes );
|
88 |
+
|
89 |
+
return implode( ' ', $classes );
|
90 |
+
}
|
91 |
+
|
92 |
+
function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
|
93 |
+
if ( is_feed() ) {
|
94 |
+
return '[contact-form-7]';
|
95 |
+
}
|
96 |
+
|
97 |
+
if ( 'contact-form-7' == $code ) {
|
98 |
+
$atts = shortcode_atts(
|
99 |
+
array(
|
100 |
+
'id' => 0,
|
101 |
+
'title' => '',
|
102 |
+
'html_id' => '',
|
103 |
+
'html_name' => '',
|
104 |
+
'html_class' => '',
|
105 |
+
'output' => 'form',
|
106 |
+
),
|
107 |
+
$atts, 'wpcf7'
|
108 |
+
);
|
109 |
+
|
110 |
+
$id = (int) $atts['id'];
|
111 |
+
$title = trim( $atts['title'] );
|
112 |
+
|
113 |
+
if ( ! $contact_form = wpcf7_contact_form( $id ) ) {
|
114 |
+
$contact_form = wpcf7_get_contact_form_by_title( $title );
|
115 |
+
}
|
116 |
+
|
117 |
+
} else {
|
118 |
+
if ( is_string( $atts ) ) {
|
119 |
+
$atts = explode( ' ', $atts, 2 );
|
120 |
+
}
|
121 |
+
|
122 |
+
$id = (int) array_shift( $atts );
|
123 |
+
$contact_form = wpcf7_get_contact_form_by_old_id( $id );
|
124 |
+
}
|
125 |
+
|
126 |
+
if ( ! $contact_form ) {
|
127 |
+
return '[contact-form-7 404 "Not Found"]';
|
128 |
+
}
|
129 |
+
|
130 |
+
return $contact_form->form_html( $atts );
|
131 |
+
}
|
132 |
+
|
133 |
+
function wpcf7_save_contact_form( $args = '', $context = 'save' ) {
|
134 |
+
$args = wp_parse_args( $args, array(
|
135 |
+
'id' => -1,
|
136 |
+
'title' => null,
|
137 |
+
'locale' => null,
|
138 |
+
'form' => null,
|
139 |
+
'mail' => null,
|
140 |
+
'mail_2' => null,
|
141 |
+
'messages' => null,
|
142 |
+
'additional_settings' => null,
|
143 |
+
) );
|
144 |
+
|
145 |
+
$args['id'] = (int) $args['id'];
|
146 |
+
|
147 |
+
if ( -1 == $args['id'] ) {
|
148 |
+
$contact_form = WPCF7_ContactForm::get_template();
|
149 |
+
} else {
|
150 |
+
$contact_form = wpcf7_contact_form( $args['id'] );
|
151 |
+
}
|
152 |
+
|
153 |
+
if ( empty( $contact_form ) ) {
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
|
157 |
+
if ( null !== $args['title'] ) {
|
158 |
+
$contact_form->set_title( $args['title'] );
|
159 |
+
}
|
160 |
+
|
161 |
+
if ( null !== $args['locale'] ) {
|
162 |
+
$contact_form->set_locale( $args['locale'] );
|
163 |
+
}
|
164 |
+
|
165 |
+
$properties = $contact_form->get_properties();
|
166 |
+
|
167 |
+
$properties['form'] = wpcf7_sanitize_form(
|
168 |
+
$args['form'], $properties['form'] );
|
169 |
+
|
170 |
+
$properties['mail'] = wpcf7_sanitize_mail(
|
171 |
+
$args['mail'], $properties['mail'] );
|
172 |
+
|
173 |
+
$properties['mail']['active'] = true;
|
174 |
+
|
175 |
+
$properties['mail_2'] = wpcf7_sanitize_mail(
|
176 |
+
$args['mail_2'], $properties['mail_2'] );
|
177 |
+
|
178 |
+
$properties['messages'] = wpcf7_sanitize_messages(
|
179 |
+
$args['messages'], $properties['messages'] );
|
180 |
+
|
181 |
+
$properties['additional_settings'] = wpcf7_sanitize_additional_settings(
|
182 |
+
$args['additional_settings'], $properties['additional_settings'] );
|
183 |
+
|
184 |
+
$contact_form->set_properties( $properties );
|
185 |
+
|
186 |
+
do_action( 'wpcf7_save_contact_form', $contact_form, $args, $context );
|
187 |
+
|
188 |
+
if ( 'save' == $context ) {
|
189 |
+
$contact_form->save();
|
190 |
+
}
|
191 |
+
|
192 |
+
return $contact_form;
|
193 |
+
}
|
194 |
+
|
195 |
+
function wpcf7_sanitize_form( $input, $default = '' ) {
|
196 |
+
if ( null === $input ) {
|
197 |
+
return $default;
|
198 |
+
}
|
199 |
+
|
200 |
+
$output = trim( $input );
|
201 |
+
return $output;
|
202 |
+
}
|
203 |
+
|
204 |
+
function wpcf7_sanitize_mail( $input, $defaults = array() ) {
|
205 |
+
$defaults = wp_parse_args( $defaults, array(
|
206 |
+
'active' => false,
|
207 |
+
'subject' => '',
|
208 |
+
'sender' => '',
|
209 |
+
'recipient' => '',
|
210 |
+
'body' => '',
|
211 |
+
'additional_headers' => '',
|
212 |
+
'attachments' => '',
|
213 |
+
'use_html' => false,
|
214 |
+
'exclude_blank' => false,
|
215 |
+
) );
|
216 |
+
|
217 |
+
$input = wp_parse_args( $input, $defaults );
|
218 |
+
|
219 |
+
$output = array();
|
220 |
+
$output['active'] = (bool) $input['active'];
|
221 |
+
$output['subject'] = trim( $input['subject'] );
|
222 |
+
$output['sender'] = trim( $input['sender'] );
|
223 |
+
$output['recipient'] = trim( $input['recipient'] );
|
224 |
+
$output['body'] = trim( $input['body'] );
|
225 |
+
$output['additional_headers'] = '';
|
226 |
+
|
227 |
+
$headers = str_replace( "\r\n", "\n", $input['additional_headers'] );
|
228 |
+
$headers = explode( "\n", $headers );
|
229 |
+
|
230 |
+
foreach ( $headers as $header ) {
|
231 |
+
$header = trim( $header );
|
232 |
+
|
233 |
+
if ( '' !== $header ) {
|
234 |
+
$output['additional_headers'] .= $header . "\n";
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
$output['additional_headers'] = trim( $output['additional_headers'] );
|
239 |
+
$output['attachments'] = trim( $input['attachments'] );
|
240 |
+
$output['use_html'] = (bool) $input['use_html'];
|
241 |
+
$output['exclude_blank'] = (bool) $input['exclude_blank'];
|
242 |
+
|
243 |
+
return $output;
|
244 |
+
}
|
245 |
+
|
246 |
+
function wpcf7_sanitize_messages( $input, $defaults = array() ) {
|
247 |
+
$output = array();
|
248 |
+
|
249 |
+
foreach ( wpcf7_messages() as $key => $val ) {
|
250 |
+
if ( isset( $input[$key] ) ) {
|
251 |
+
$output[$key] = trim( $input[$key] );
|
252 |
+
} elseif ( isset( $defaults[$key] ) ) {
|
253 |
+
$output[$key] = $defaults[$key];
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
return $output;
|
258 |
+
}
|
259 |
+
|
260 |
+
function wpcf7_sanitize_additional_settings( $input, $default = '' ) {
|
261 |
+
if ( null === $input ) {
|
262 |
+
return $default;
|
263 |
+
}
|
264 |
+
|
265 |
+
$output = trim( $input );
|
266 |
+
return $output;
|
267 |
+
}
|
includes/contact-form-template.php
CHANGED
@@ -57,14 +57,15 @@ class WPCF7_ContactFormTemplate {
|
|
57 |
'[your-subject]' ) . "\n\n"
|
58 |
. __( 'Message Body:', 'contact-form-7' )
|
59 |
. "\n" . '[your-message]' . "\n\n"
|
60 |
-
. '--' . "\n"
|
61 |
. sprintf( __( 'This e-mail was sent from a contact form on %1$s (%2$s)',
|
62 |
'contact-form-7' ), get_bloginfo( 'name' ), get_bloginfo( 'url' ) ),
|
63 |
'recipient' => get_option( 'admin_email' ),
|
64 |
'additional_headers' => 'Reply-To: [your-email]',
|
65 |
'attachments' => '',
|
66 |
'use_html' => 0,
|
67 |
-
'exclude_blank' => 0
|
|
|
68 |
|
69 |
return $template;
|
70 |
}
|
@@ -80,7 +81,7 @@ class WPCF7_ContactFormTemplate {
|
|
80 |
'body' =>
|
81 |
__( 'Message Body:', 'contact-form-7' )
|
82 |
. "\n" . '[your-message]' . "\n\n"
|
83 |
-
. '--' . "\n"
|
84 |
. sprintf( __( 'This e-mail was sent from a contact form on %1$s (%2$s)',
|
85 |
'contact-form-7' ), get_bloginfo( 'name' ), get_bloginfo( 'url' ) ),
|
86 |
'recipient' => '[your-email]',
|
@@ -88,7 +89,8 @@ class WPCF7_ContactFormTemplate {
|
|
88 |
get_option( 'admin_email' ) ),
|
89 |
'attachments' => '',
|
90 |
'use_html' => 0,
|
91 |
-
'exclude_blank' => 0
|
|
|
92 |
|
93 |
return $template;
|
94 |
}
|
@@ -129,56 +131,56 @@ function wpcf7_messages() {
|
|
129 |
'description'
|
130 |
=> __( "Sender's message was sent successfully", 'contact-form-7' ),
|
131 |
'default'
|
132 |
-
=> __( "Thank you for your message. It has been sent.", 'contact-form-7' )
|
133 |
),
|
134 |
|
135 |
'mail_sent_ng' => array(
|
136 |
'description'
|
137 |
=> __( "Sender's message failed to send", 'contact-form-7' ),
|
138 |
'default'
|
139 |
-
=> __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' )
|
140 |
),
|
141 |
|
142 |
'validation_error' => array(
|
143 |
'description'
|
144 |
=> __( "Validation errors occurred", 'contact-form-7' ),
|
145 |
'default'
|
146 |
-
=> __( "One or more fields have an error. Please check and try again.", 'contact-form-7' )
|
147 |
),
|
148 |
|
149 |
'spam' => array(
|
150 |
'description'
|
151 |
=> __( "Submission was referred to as spam", 'contact-form-7' ),
|
152 |
'default'
|
153 |
-
=> __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' )
|
154 |
),
|
155 |
|
156 |
'accept_terms' => array(
|
157 |
'description'
|
158 |
=> __( "There are terms that the sender must accept", 'contact-form-7' ),
|
159 |
'default'
|
160 |
-
=> __( "You must accept the terms and conditions before sending your message.", 'contact-form-7' )
|
161 |
),
|
162 |
|
163 |
'invalid_required' => array(
|
164 |
'description'
|
165 |
=> __( "There is a field that the sender must fill in", 'contact-form-7' ),
|
166 |
'default'
|
167 |
-
=> __( "The field is required.", 'contact-form-7' )
|
168 |
),
|
169 |
|
170 |
'invalid_too_long' => array(
|
171 |
'description'
|
172 |
=> __( "There is a field with input that is longer than the maximum allowed length", 'contact-form-7' ),
|
173 |
'default'
|
174 |
-
=> __( "The field is too long.", 'contact-form-7' )
|
175 |
),
|
176 |
|
177 |
'invalid_too_short' => array(
|
178 |
'description'
|
179 |
=> __( "There is a field with input that is shorter than the minimum allowed length", 'contact-form-7' ),
|
180 |
'default'
|
181 |
-
=> __( "The field is too short.", 'contact-form-7' )
|
182 |
)
|
183 |
);
|
184 |
|
57 |
'[your-subject]' ) . "\n\n"
|
58 |
. __( 'Message Body:', 'contact-form-7' )
|
59 |
. "\n" . '[your-message]' . "\n\n"
|
60 |
+
. '-- ' . "\n"
|
61 |
. sprintf( __( 'This e-mail was sent from a contact form on %1$s (%2$s)',
|
62 |
'contact-form-7' ), get_bloginfo( 'name' ), get_bloginfo( 'url' ) ),
|
63 |
'recipient' => get_option( 'admin_email' ),
|
64 |
'additional_headers' => 'Reply-To: [your-email]',
|
65 |
'attachments' => '',
|
66 |
'use_html' => 0,
|
67 |
+
'exclude_blank' => 0,
|
68 |
+
);
|
69 |
|
70 |
return $template;
|
71 |
}
|
81 |
'body' =>
|
82 |
__( 'Message Body:', 'contact-form-7' )
|
83 |
. "\n" . '[your-message]' . "\n\n"
|
84 |
+
. '-- ' . "\n"
|
85 |
. sprintf( __( 'This e-mail was sent from a contact form on %1$s (%2$s)',
|
86 |
'contact-form-7' ), get_bloginfo( 'name' ), get_bloginfo( 'url' ) ),
|
87 |
'recipient' => '[your-email]',
|
89 |
get_option( 'admin_email' ) ),
|
90 |
'attachments' => '',
|
91 |
'use_html' => 0,
|
92 |
+
'exclude_blank' => 0,
|
93 |
+
);
|
94 |
|
95 |
return $template;
|
96 |
}
|
131 |
'description'
|
132 |
=> __( "Sender's message was sent successfully", 'contact-form-7' ),
|
133 |
'default'
|
134 |
+
=> __( "Thank you for your message. It has been sent.", 'contact-form-7' ),
|
135 |
),
|
136 |
|
137 |
'mail_sent_ng' => array(
|
138 |
'description'
|
139 |
=> __( "Sender's message failed to send", 'contact-form-7' ),
|
140 |
'default'
|
141 |
+
=> __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' ),
|
142 |
),
|
143 |
|
144 |
'validation_error' => array(
|
145 |
'description'
|
146 |
=> __( "Validation errors occurred", 'contact-form-7' ),
|
147 |
'default'
|
148 |
+
=> __( "One or more fields have an error. Please check and try again.", 'contact-form-7' ),
|
149 |
),
|
150 |
|
151 |
'spam' => array(
|
152 |
'description'
|
153 |
=> __( "Submission was referred to as spam", 'contact-form-7' ),
|
154 |
'default'
|
155 |
+
=> __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' ),
|
156 |
),
|
157 |
|
158 |
'accept_terms' => array(
|
159 |
'description'
|
160 |
=> __( "There are terms that the sender must accept", 'contact-form-7' ),
|
161 |
'default'
|
162 |
+
=> __( "You must accept the terms and conditions before sending your message.", 'contact-form-7' ),
|
163 |
),
|
164 |
|
165 |
'invalid_required' => array(
|
166 |
'description'
|
167 |
=> __( "There is a field that the sender must fill in", 'contact-form-7' ),
|
168 |
'default'
|
169 |
+
=> __( "The field is required.", 'contact-form-7' ),
|
170 |
),
|
171 |
|
172 |
'invalid_too_long' => array(
|
173 |
'description'
|
174 |
=> __( "There is a field with input that is longer than the maximum allowed length", 'contact-form-7' ),
|
175 |
'default'
|
176 |
+
=> __( "The field is too long.", 'contact-form-7' ),
|
177 |
),
|
178 |
|
179 |
'invalid_too_short' => array(
|
180 |
'description'
|
181 |
=> __( "There is a field with input that is shorter than the minimum allowed length", 'contact-form-7' ),
|
182 |
'default'
|
183 |
+
=> __( "The field is too short.", 'contact-form-7' ),
|
184 |
)
|
185 |
);
|
186 |
|
includes/contact-form.php
CHANGED
@@ -10,6 +10,7 @@ class WPCF7_ContactForm {
|
|
10 |
private $id;
|
11 |
private $name;
|
12 |
private $title;
|
|
|
13 |
private $properties = array();
|
14 |
private $unit_tag;
|
15 |
private $responses_count = 0;
|
@@ -28,9 +29,11 @@ class WPCF7_ContactForm {
|
|
28 |
register_post_type( self::post_type, array(
|
29 |
'labels' => array(
|
30 |
'name' => __( 'Contact Forms', 'contact-form-7' ),
|
31 |
-
'singular_name' => __( 'Contact Form', 'contact-form-7' )
|
|
|
32 |
'rewrite' => false,
|
33 |
-
'query_var' => false
|
|
|
34 |
}
|
35 |
|
36 |
public static function find( $args = '' ) {
|
@@ -39,7 +42,8 @@ class WPCF7_ContactForm {
|
|
39 |
'posts_per_page' => -1,
|
40 |
'offset' => 0,
|
41 |
'orderby' => 'ID',
|
42 |
-
'order' => 'ASC'
|
|
|
43 |
|
44 |
$args = wp_parse_args( $args, $defaults );
|
45 |
|
@@ -52,8 +56,9 @@ class WPCF7_ContactForm {
|
|
52 |
|
53 |
$objs = array();
|
54 |
|
55 |
-
foreach ( (array) $posts as $post )
|
56 |
$objs[] = new self( $post );
|
|
|
57 |
|
58 |
return $objs;
|
59 |
}
|
@@ -189,7 +194,8 @@ class WPCF7_ContactForm {
|
|
189 |
'mail' => array(),
|
190 |
'mail_2' => array(),
|
191 |
'messages' => array(),
|
192 |
-
'additional_settings' => ''
|
|
|
193 |
|
194 |
$properties = (array) apply_filters( 'wpcf7_contact_form_properties',
|
195 |
$properties, $this );
|
@@ -219,6 +225,7 @@ class WPCF7_ContactForm {
|
|
219 |
}
|
220 |
|
221 |
public function set_title( $title ) {
|
|
|
222 |
$title = trim( $title );
|
223 |
|
224 |
if ( '' === $title ) {
|
@@ -228,6 +235,24 @@ class WPCF7_ContactForm {
|
|
228 |
$this->title = $title;
|
229 |
}
|
230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
public function shortcode_attr( $name ) {
|
232 |
if ( isset( $this->shortcode_atts[$name] ) ) {
|
233 |
return (string) $this->shortcode_atts[$name];
|
@@ -254,7 +279,8 @@ class WPCF7_ContactForm {
|
|
254 |
'html_id' => '',
|
255 |
'html_name' => '',
|
256 |
'html_class' => '',
|
257 |
-
'output' => 'form'
|
|
|
258 |
|
259 |
$this->shortcode_atts = $args;
|
260 |
|
@@ -271,15 +297,18 @@ class WPCF7_ContactForm {
|
|
271 |
$lang_tag = $matches[1];
|
272 |
}
|
273 |
|
274 |
-
$html = sprintf( '<div %s>',
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
|
|
|
|
|
|
281 |
|
282 |
-
$html .= $this->screen_reader_response() . "\n";
|
283 |
|
284 |
$url = wpcf7_get_request_uri();
|
285 |
|
@@ -340,7 +369,8 @@ class WPCF7_ContactForm {
|
|
340 |
'class' => $class,
|
341 |
'enctype' => wpcf7_enctype_value( $enctype ),
|
342 |
'autocomplete' => $autocomplete,
|
343 |
-
'novalidate' => $novalidate ? 'novalidate' : ''
|
|
|
344 |
|
345 |
if ( '' !== $id_attr ) {
|
346 |
$atts['id'] = $id_attr;
|
@@ -371,7 +401,8 @@ class WPCF7_ContactForm {
|
|
371 |
'_wpcf7' => $this->id,
|
372 |
'_wpcf7_version' => WPCF7_VERSION,
|
373 |
'_wpcf7_locale' => $this->locale,
|
374 |
-
'_wpcf7_unit_tag' => $this->unit_tag
|
|
|
375 |
|
376 |
if ( WPCF7_VERIFY_NONCE ) {
|
377 |
$hidden_fields['_wpnonce'] = wpcf7_create_nonce( $this->id );
|
@@ -417,7 +448,8 @@ class WPCF7_ContactForm {
|
|
417 |
|
418 |
$atts = array(
|
419 |
'class' => trim( $class ),
|
420 |
-
'role' => trim( $role )
|
|
|
421 |
|
422 |
$atts = wpcf7_format_atts( $atts );
|
423 |
|
@@ -528,53 +560,13 @@ class WPCF7_ContactForm {
|
|
528 |
public function scan_form_tags( $cond = null ) {
|
529 |
$manager = WPCF7_FormTagsManager::get_instance();
|
530 |
|
531 |
-
if (
|
532 |
-
$
|
533 |
-
} else {
|
534 |
-
$scanned = $manager->scan( $this->prop( 'form' ) );
|
535 |
-
$this->scanned_form_tags = $scanned;
|
536 |
}
|
537 |
|
538 |
-
|
539 |
-
return array();
|
540 |
-
}
|
541 |
-
|
542 |
-
if ( ! is_array( $cond ) || empty( $cond ) ) {
|
543 |
-
return $scanned;
|
544 |
-
}
|
545 |
|
546 |
-
|
547 |
-
|
548 |
-
if ( isset( $cond['type'] ) ) {
|
549 |
-
if ( is_string( $cond['type'] ) && ! empty( $cond['type'] ) ) {
|
550 |
-
if ( $scanned[$i]['type'] != $cond['type'] ) {
|
551 |
-
unset( $scanned[$i] );
|
552 |
-
continue;
|
553 |
-
}
|
554 |
-
} elseif ( is_array( $cond['type'] ) ) {
|
555 |
-
if ( ! in_array( $scanned[$i]['type'], $cond['type'] ) ) {
|
556 |
-
unset( $scanned[$i] );
|
557 |
-
continue;
|
558 |
-
}
|
559 |
-
}
|
560 |
-
}
|
561 |
-
|
562 |
-
if ( isset( $cond['name'] ) ) {
|
563 |
-
if ( is_string( $cond['name'] ) && ! empty( $cond['name'] ) ) {
|
564 |
-
if ( $scanned[$i]['name'] != $cond['name'] ) {
|
565 |
-
unset ( $scanned[$i] );
|
566 |
-
continue;
|
567 |
-
}
|
568 |
-
} elseif ( is_array( $cond['name'] ) ) {
|
569 |
-
if ( ! in_array( $scanned[$i]['name'], $cond['name'] ) ) {
|
570 |
-
unset( $scanned[$i] );
|
571 |
-
continue;
|
572 |
-
}
|
573 |
-
}
|
574 |
-
}
|
575 |
-
}
|
576 |
-
|
577 |
-
return array_values( $scanned );
|
578 |
}
|
579 |
|
580 |
public function form_scan_shortcode( $cond = null ) {
|
@@ -592,8 +584,9 @@ class WPCF7_ContactForm {
|
|
592 |
public function collect_mail_tags( $args = '' ) {
|
593 |
$args = wp_parse_args( $args, array(
|
594 |
'include' => array(),
|
595 |
-
'exclude' =>
|
596 |
-
'acceptance', 'captchac', 'captchar', 'quiz', 'count' )
|
|
|
597 |
|
598 |
$tags = $this->scan_form_tags();
|
599 |
$mailtags = array();
|
@@ -622,10 +615,19 @@ class WPCF7_ContactForm {
|
|
622 |
}
|
623 |
|
624 |
public function suggest_mail_tags( $for = 'mail' ) {
|
625 |
-
$mail = wp_parse_args( $this->prop( $for ),
|
626 |
-
|
627 |
-
|
628 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
|
630 |
$mail = array_filter( $mail );
|
631 |
|
@@ -645,9 +647,11 @@ class WPCF7_ContactForm {
|
|
645 |
$submission = WPCF7_Submission::get_instance( $this );
|
646 |
|
647 |
$result = array(
|
|
|
648 |
'status' => $submission->get_status(),
|
649 |
'message' => $submission->get_response(),
|
650 |
-
'demo_mode' => $this->in_demo_mode()
|
|
|
651 |
|
652 |
if ( $submission->is( 'validation_failed' ) ) {
|
653 |
$result['invalid_fields'] = $submission->get_invalid_fields();
|
@@ -770,13 +774,15 @@ class WPCF7_ContactForm {
|
|
770 |
'post_type' => self::post_type,
|
771 |
'post_status' => 'publish',
|
772 |
'post_title' => $this->title,
|
773 |
-
'post_content' => trim( $post_content )
|
|
|
774 |
} else {
|
775 |
$post_id = wp_update_post( array(
|
776 |
'ID' => (int) $this->id,
|
777 |
'post_status' => 'publish',
|
778 |
'post_title' => $this->title,
|
779 |
-
'post_content' => trim( $post_content )
|
|
|
780 |
}
|
781 |
|
782 |
if ( $post_id ) {
|
@@ -812,8 +818,9 @@ class WPCF7_ContactForm {
|
|
812 |
}
|
813 |
|
814 |
public function delete() {
|
815 |
-
if ( $this->initial() )
|
816 |
return;
|
|
|
817 |
|
818 |
if ( wp_delete_post( $this->id, true ) ) {
|
819 |
$this->id = 0;
|
@@ -845,129 +852,3 @@ class WPCF7_ContactForm {
|
|
845 |
return apply_filters( 'wpcf7_contact_form_shortcode', $shortcode, $args, $this );
|
846 |
}
|
847 |
}
|
848 |
-
|
849 |
-
function wpcf7_contact_form( $id ) {
|
850 |
-
return WPCF7_ContactForm::get_instance( $id );
|
851 |
-
}
|
852 |
-
|
853 |
-
function wpcf7_get_contact_form_by_old_id( $old_id ) {
|
854 |
-
global $wpdb;
|
855 |
-
|
856 |
-
$q = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_old_cf7_unit_id'"
|
857 |
-
. $wpdb->prepare( " AND meta_value = %d", $old_id );
|
858 |
-
|
859 |
-
if ( $new_id = $wpdb->get_var( $q ) ) {
|
860 |
-
return wpcf7_contact_form( $new_id );
|
861 |
-
}
|
862 |
-
}
|
863 |
-
|
864 |
-
function wpcf7_get_contact_form_by_title( $title ) {
|
865 |
-
$page = get_page_by_title( $title, OBJECT, WPCF7_ContactForm::post_type );
|
866 |
-
|
867 |
-
if ( $page ) {
|
868 |
-
return wpcf7_contact_form( $page->ID );
|
869 |
-
}
|
870 |
-
|
871 |
-
return null;
|
872 |
-
}
|
873 |
-
|
874 |
-
function wpcf7_get_current_contact_form() {
|
875 |
-
if ( $current = WPCF7_ContactForm::get_current() ) {
|
876 |
-
return $current;
|
877 |
-
}
|
878 |
-
}
|
879 |
-
|
880 |
-
function wpcf7_is_posted() {
|
881 |
-
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
882 |
-
return false;
|
883 |
-
}
|
884 |
-
|
885 |
-
return $contact_form->is_posted();
|
886 |
-
}
|
887 |
-
|
888 |
-
function wpcf7_get_hangover( $name, $default = null ) {
|
889 |
-
if ( ! wpcf7_is_posted() ) {
|
890 |
-
return $default;
|
891 |
-
}
|
892 |
-
|
893 |
-
$submission = WPCF7_Submission::get_instance();
|
894 |
-
|
895 |
-
if ( ! $submission || $submission->is( 'mail_sent' ) ) {
|
896 |
-
return $default;
|
897 |
-
}
|
898 |
-
|
899 |
-
return isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : $default;
|
900 |
-
}
|
901 |
-
|
902 |
-
function wpcf7_get_validation_error( $name ) {
|
903 |
-
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
904 |
-
return '';
|
905 |
-
}
|
906 |
-
|
907 |
-
return $contact_form->validation_error( $name );
|
908 |
-
}
|
909 |
-
|
910 |
-
function wpcf7_get_message( $status ) {
|
911 |
-
if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
|
912 |
-
return '';
|
913 |
-
}
|
914 |
-
|
915 |
-
return $contact_form->message( $status );
|
916 |
-
}
|
917 |
-
|
918 |
-
function wpcf7_form_controls_class( $type, $default = '' ) {
|
919 |
-
$type = trim( $type );
|
920 |
-
$default = array_filter( explode( ' ', $default ) );
|
921 |
-
|
922 |
-
$classes = array_merge( array( 'wpcf7-form-control' ), $default );
|
923 |
-
|
924 |
-
$typebase = rtrim( $type, '*' );
|
925 |
-
$required = ( '*' == substr( $type, -1 ) );
|
926 |
-
|
927 |
-
$classes[] = 'wpcf7-' . $typebase;
|
928 |
-
|
929 |
-
if ( $required ) {
|
930 |
-
$classes[] = 'wpcf7-validates-as-required';
|
931 |
-
}
|
932 |
-
|
933 |
-
$classes = array_unique( $classes );
|
934 |
-
|
935 |
-
return implode( ' ', $classes );
|
936 |
-
}
|
937 |
-
|
938 |
-
function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
|
939 |
-
if ( is_feed() ) {
|
940 |
-
return '[contact-form-7]';
|
941 |
-
}
|
942 |
-
|
943 |
-
if ( 'contact-form-7' == $code ) {
|
944 |
-
$atts = shortcode_atts( array(
|
945 |
-
'id' => 0,
|
946 |
-
'title' => '',
|
947 |
-
'html_id' => '',
|
948 |
-
'html_name' => '',
|
949 |
-
'html_class' => '',
|
950 |
-
'output' => 'form' ), $atts, 'wpcf7' );
|
951 |
-
|
952 |
-
$id = (int) $atts['id'];
|
953 |
-
$title = trim( $atts['title'] );
|
954 |
-
|
955 |
-
if ( ! $contact_form = wpcf7_contact_form( $id ) ) {
|
956 |
-
$contact_form = wpcf7_get_contact_form_by_title( $title );
|
957 |
-
}
|
958 |
-
|
959 |
-
} else {
|
960 |
-
if ( is_string( $atts ) ) {
|
961 |
-
$atts = explode( ' ', $atts, 2 );
|
962 |
-
}
|
963 |
-
|
964 |
-
$id = (int) array_shift( $atts );
|
965 |
-
$contact_form = wpcf7_get_contact_form_by_old_id( $id );
|
966 |
-
}
|
967 |
-
|
968 |
-
if ( ! $contact_form ) {
|
969 |
-
return '[contact-form-7 404 "Not Found"]';
|
970 |
-
}
|
971 |
-
|
972 |
-
return $contact_form->form_html( $atts );
|
973 |
-
}
|
10 |
private $id;
|
11 |
private $name;
|
12 |
private $title;
|
13 |
+
private $locale;
|
14 |
private $properties = array();
|
15 |
private $unit_tag;
|
16 |
private $responses_count = 0;
|
29 |
register_post_type( self::post_type, array(
|
30 |
'labels' => array(
|
31 |
'name' => __( 'Contact Forms', 'contact-form-7' ),
|
32 |
+
'singular_name' => __( 'Contact Form', 'contact-form-7' ),
|
33 |
+
),
|
34 |
'rewrite' => false,
|
35 |
+
'query_var' => false,
|
36 |
+
) );
|
37 |
}
|
38 |
|
39 |
public static function find( $args = '' ) {
|
42 |
'posts_per_page' => -1,
|
43 |
'offset' => 0,
|
44 |
'orderby' => 'ID',
|
45 |
+
'order' => 'ASC',
|
46 |
+
);
|
47 |
|
48 |
$args = wp_parse_args( $args, $defaults );
|
49 |
|
56 |
|
57 |
$objs = array();
|
58 |
|
59 |
+
foreach ( (array) $posts as $post ) {
|
60 |
$objs[] = new self( $post );
|
61 |
+
}
|
62 |
|
63 |
return $objs;
|
64 |
}
|
194 |
'mail' => array(),
|
195 |
'mail_2' => array(),
|
196 |
'messages' => array(),
|
197 |
+
'additional_settings' => '',
|
198 |
+
) );
|
199 |
|
200 |
$properties = (array) apply_filters( 'wpcf7_contact_form_properties',
|
201 |
$properties, $this );
|
225 |
}
|
226 |
|
227 |
public function set_title( $title ) {
|
228 |
+
$title = strip_tags( $title );
|
229 |
$title = trim( $title );
|
230 |
|
231 |
if ( '' === $title ) {
|
235 |
$this->title = $title;
|
236 |
}
|
237 |
|
238 |
+
public function locale() {
|
239 |
+
if ( wpcf7_is_valid_locale( $this->locale ) ) {
|
240 |
+
return $this->locale;
|
241 |
+
} else {
|
242 |
+
return '';
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
public function set_locale( $locale ) {
|
247 |
+
$locale = trim( $locale );
|
248 |
+
|
249 |
+
if ( wpcf7_is_valid_locale( $locale ) ) {
|
250 |
+
$this->locale = $locale;
|
251 |
+
} else {
|
252 |
+
$this->locale = 'en_US';
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
public function shortcode_attr( $name ) {
|
257 |
if ( isset( $this->shortcode_atts[$name] ) ) {
|
258 |
return (string) $this->shortcode_atts[$name];
|
279 |
'html_id' => '',
|
280 |
'html_name' => '',
|
281 |
'html_class' => '',
|
282 |
+
'output' => 'form',
|
283 |
+
) );
|
284 |
|
285 |
$this->shortcode_atts = $args;
|
286 |
|
297 |
$lang_tag = $matches[1];
|
298 |
}
|
299 |
|
300 |
+
$html = sprintf( '<div %s>',
|
301 |
+
wpcf7_format_atts( array(
|
302 |
+
'role' => 'form',
|
303 |
+
'class' => 'wpcf7',
|
304 |
+
'id' => $this->unit_tag,
|
305 |
+
( get_option( 'html_type' ) == 'text/html' ) ? 'lang' : 'xml:lang'
|
306 |
+
=> $lang_tag,
|
307 |
+
'dir' => wpcf7_is_rtl( $this->locale ) ? 'rtl' : 'ltr',
|
308 |
+
) )
|
309 |
+
);
|
310 |
|
311 |
+
$html .= "\n" . $this->screen_reader_response() . "\n";
|
312 |
|
313 |
$url = wpcf7_get_request_uri();
|
314 |
|
369 |
'class' => $class,
|
370 |
'enctype' => wpcf7_enctype_value( $enctype ),
|
371 |
'autocomplete' => $autocomplete,
|
372 |
+
'novalidate' => $novalidate ? 'novalidate' : '',
|
373 |
+
);
|
374 |
|
375 |
if ( '' !== $id_attr ) {
|
376 |
$atts['id'] = $id_attr;
|
401 |
'_wpcf7' => $this->id,
|
402 |
'_wpcf7_version' => WPCF7_VERSION,
|
403 |
'_wpcf7_locale' => $this->locale,
|
404 |
+
'_wpcf7_unit_tag' => $this->unit_tag,
|
405 |
+
);
|
406 |
|
407 |
if ( WPCF7_VERIFY_NONCE ) {
|
408 |
$hidden_fields['_wpnonce'] = wpcf7_create_nonce( $this->id );
|
448 |
|
449 |
$atts = array(
|
450 |
'class' => trim( $class ),
|
451 |
+
'role' => trim( $role ),
|
452 |
+
);
|
453 |
|
454 |
$atts = wpcf7_format_atts( $atts );
|
455 |
|
560 |
public function scan_form_tags( $cond = null ) {
|
561 |
$manager = WPCF7_FormTagsManager::get_instance();
|
562 |
|
563 |
+
if ( empty( $this->scanned_form_tags ) ) {
|
564 |
+
$this->scanned_form_tags = $manager->scan( $this->prop( 'form' ) );
|
|
|
|
|
|
|
565 |
}
|
566 |
|
567 |
+
$tags = $this->scanned_form_tags;
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
|
569 |
+
return $manager->filter( $tags, $cond );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
570 |
}
|
571 |
|
572 |
public function form_scan_shortcode( $cond = null ) {
|
584 |
public function collect_mail_tags( $args = '' ) {
|
585 |
$args = wp_parse_args( $args, array(
|
586 |
'include' => array(),
|
587 |
+
'exclude' =>
|
588 |
+
array( 'acceptance', 'captchac', 'captchar', 'quiz', 'count' ),
|
589 |
+
) );
|
590 |
|
591 |
$tags = $this->scan_form_tags();
|
592 |
$mailtags = array();
|
615 |
}
|
616 |
|
617 |
public function suggest_mail_tags( $for = 'mail' ) {
|
618 |
+
$mail = wp_parse_args( $this->prop( $for ),
|
619 |
+
array(
|
620 |
+
'active' => false,
|
621 |
+
'recipient' => '',
|
622 |
+
'sender' => '',
|
623 |
+
'subject' => '',
|
624 |
+
'body' => '',
|
625 |
+
'additional_headers' => '',
|
626 |
+
'attachments' => '',
|
627 |
+
'use_html' => false,
|
628 |
+
'exclude_blank' => false,
|
629 |
+
)
|
630 |
+
);
|
631 |
|
632 |
$mail = array_filter( $mail );
|
633 |
|
647 |
$submission = WPCF7_Submission::get_instance( $this );
|
648 |
|
649 |
$result = array(
|
650 |
+
'contact_form_id' => $this->id(),
|
651 |
'status' => $submission->get_status(),
|
652 |
'message' => $submission->get_response(),
|
653 |
+
'demo_mode' => $this->in_demo_mode(),
|
654 |
+
);
|
655 |
|
656 |
if ( $submission->is( 'validation_failed' ) ) {
|
657 |
$result['invalid_fields'] = $submission->get_invalid_fields();
|
774 |
'post_type' => self::post_type,
|
775 |
'post_status' => 'publish',
|
776 |
'post_title' => $this->title,
|
777 |
+
'post_content' => trim( $post_content ),
|
778 |
+
) );
|
779 |
} else {
|
780 |
$post_id = wp_update_post( array(
|
781 |
'ID' => (int) $this->id,
|
782 |
'post_status' => 'publish',
|
783 |
'post_title' => $this->title,
|
784 |
+
'post_content' => trim( $post_content ),
|
785 |
+
) );
|
786 |
}
|
787 |
|
788 |
if ( $post_id ) {
|
818 |
}
|
819 |
|
820 |
public function delete() {
|
821 |
+
if ( $this->initial() ) {
|
822 |
return;
|
823 |
+
}
|
824 |
|
825 |
if ( wp_delete_post( $this->id, true ) ) {
|
826 |
$this->id = 0;
|
852 |
return apply_filters( 'wpcf7_contact_form_shortcode', $shortcode, $args, $this );
|
853 |
}
|
854 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/controller.php
CHANGED
@@ -52,7 +52,8 @@ function wpcf7_ajax_json_echo() {
|
|
52 |
$items = array(
|
53 |
'mailSent' => false,
|
54 |
'into' => '#' . $unit_tag,
|
55 |
-
'captcha' => null
|
|
|
56 |
|
57 |
$result = $contact_form->submit( true );
|
58 |
|
@@ -72,7 +73,8 @@ function wpcf7_ajax_json_echo() {
|
|
72 |
'into' => 'span.wpcf7-form-control-wrap.'
|
73 |
. sanitize_html_class( $name ),
|
74 |
'message' => $field['reason'],
|
75 |
-
'idref' => $field['idref']
|
|
|
76 |
}
|
77 |
|
78 |
$items['invalids'] = $invalids;
|
@@ -108,15 +110,17 @@ function wpcf7_ajax_json_echo() {
|
|
108 |
}
|
109 |
|
110 |
function wpcf7_is_xhr() {
|
111 |
-
if ( ! isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) )
|
112 |
return false;
|
|
|
113 |
|
114 |
return $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
|
115 |
}
|
116 |
|
117 |
function wpcf7_submit_nonajax() {
|
118 |
-
if ( ! isset( $_POST['_wpcf7'] ) )
|
119 |
return;
|
|
|
120 |
|
121 |
if ( $contact_form = wpcf7_contact_form( (int) $_POST['_wpcf7'] ) ) {
|
122 |
$contact_form->submit();
|
@@ -126,8 +130,11 @@ function wpcf7_submit_nonajax() {
|
|
126 |
add_filter( 'widget_text', 'wpcf7_widget_text_filter', 9 );
|
127 |
|
128 |
function wpcf7_widget_text_filter( $content ) {
|
129 |
-
|
|
|
|
|
130 |
return $content;
|
|
|
131 |
|
132 |
$content = do_shortcode( $content );
|
133 |
|
@@ -167,8 +174,11 @@ function wpcf7_enqueue_scripts() {
|
|
167 |
$_wpcf7 = array(
|
168 |
'recaptcha' => array(
|
169 |
'messages' => array(
|
170 |
-
'empty' =>
|
171 |
-
'contact-form-7' )
|
|
|
|
|
|
|
172 |
|
173 |
if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
|
174 |
$_wpcf7['cached'] = 1;
|
52 |
$items = array(
|
53 |
'mailSent' => false,
|
54 |
'into' => '#' . $unit_tag,
|
55 |
+
'captcha' => null,
|
56 |
+
);
|
57 |
|
58 |
$result = $contact_form->submit( true );
|
59 |
|
73 |
'into' => 'span.wpcf7-form-control-wrap.'
|
74 |
. sanitize_html_class( $name ),
|
75 |
'message' => $field['reason'],
|
76 |
+
'idref' => $field['idref'],
|
77 |
+
);
|
78 |
}
|
79 |
|
80 |
$items['invalids'] = $invalids;
|
110 |
}
|
111 |
|
112 |
function wpcf7_is_xhr() {
|
113 |
+
if ( ! isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) ) {
|
114 |
return false;
|
115 |
+
}
|
116 |
|
117 |
return $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
|
118 |
}
|
119 |
|
120 |
function wpcf7_submit_nonajax() {
|
121 |
+
if ( ! isset( $_POST['_wpcf7'] ) ) {
|
122 |
return;
|
123 |
+
}
|
124 |
|
125 |
if ( $contact_form = wpcf7_contact_form( (int) $_POST['_wpcf7'] ) ) {
|
126 |
$contact_form->submit();
|
130 |
add_filter( 'widget_text', 'wpcf7_widget_text_filter', 9 );
|
131 |
|
132 |
function wpcf7_widget_text_filter( $content ) {
|
133 |
+
$pattern = '/\[[\r\n\t ]*contact-form(-7)?[\r\n\t ].*?\]/';
|
134 |
+
|
135 |
+
if ( ! preg_match( $pattern, $content ) ) {
|
136 |
return $content;
|
137 |
+
}
|
138 |
|
139 |
$content = do_shortcode( $content );
|
140 |
|
174 |
$_wpcf7 = array(
|
175 |
'recaptcha' => array(
|
176 |
'messages' => array(
|
177 |
+
'empty' =>
|
178 |
+
__( 'Please verify that you are not a robot.', 'contact-form-7' ),
|
179 |
+
),
|
180 |
+
),
|
181 |
+
);
|
182 |
|
183 |
if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
|
184 |
$_wpcf7['cached'] = 1;
|
includes/css/styles.css
CHANGED
@@ -42,6 +42,7 @@ div.wpcf7-validation-errors {
|
|
42 |
span.wpcf7-not-valid-tip {
|
43 |
color: #f00;
|
44 |
font-size: 1em;
|
|
|
45 |
display: block;
|
46 |
}
|
47 |
|
42 |
span.wpcf7-not-valid-tip {
|
43 |
color: #f00;
|
44 |
font-size: 1em;
|
45 |
+
font-weight: normal;
|
46 |
display: block;
|
47 |
}
|
48 |
|
includes/form-tag.php
CHANGED
@@ -36,7 +36,8 @@ class WPCF7_FormTag {
|
|
36 |
'int' => '[0-9]+',
|
37 |
'signed_int' => '-?[0-9]+',
|
38 |
'class' => '[-0-9a-zA-Z_]+',
|
39 |
-
'id' => '[-0-9a-zA-Z_]+'
|
|
|
40 |
|
41 |
if ( isset( $preset_patterns[$pattern] ) ) {
|
42 |
$pattern = $preset_patterns[$pattern];
|
36 |
'int' => '[0-9]+',
|
37 |
'signed_int' => '-?[0-9]+',
|
38 |
'class' => '[-0-9a-zA-Z_]+',
|
39 |
+
'id' => '[-0-9a-zA-Z_]+',
|
40 |
+
);
|
41 |
|
42 |
if ( isset( $preset_patterns[$pattern] ) ) {
|
43 |
$pattern = $preset_patterns[$pattern];
|
includes/form-tags-manager.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
function wpcf7_add_form_tag( $tag, $func, $
|
4 |
$manager = WPCF7_FormTagsManager::get_instance();
|
5 |
|
6 |
-
return $manager->add( $tag, $func, $
|
7 |
}
|
8 |
|
9 |
function wpcf7_remove_form_tag( $tag ) {
|
@@ -28,11 +28,17 @@ function wpcf7_scan_form_tags( $cond = null ) {
|
|
28 |
return array();
|
29 |
}
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
class WPCF7_FormTagsManager {
|
32 |
|
33 |
private static $instance;
|
34 |
|
35 |
-
private $
|
36 |
private $scanned_tags = null; // Tags scanned at the last time of scan()
|
37 |
|
38 |
private function __construct() {}
|
@@ -49,26 +55,41 @@ class WPCF7_FormTagsManager {
|
|
49 |
return $this->scanned_tags;
|
50 |
}
|
51 |
|
52 |
-
public function add( $tag, $func, $
|
53 |
if ( ! is_callable( $func ) ) {
|
54 |
return;
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
$tags = array_filter( array_unique( (array) $tag ) );
|
58 |
|
59 |
foreach ( $tags as $tag ) {
|
60 |
$tag = $this->sanitize_tag_type( $tag );
|
61 |
|
62 |
if ( ! $this->tag_type_exists( $tag ) ) {
|
63 |
-
$this->
|
64 |
'function' => $func,
|
65 |
-
'
|
|
|
66 |
}
|
67 |
}
|
68 |
}
|
69 |
|
70 |
public function tag_type_exists( $tag ) {
|
71 |
-
return isset( $this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
|
74 |
private function sanitize_tag_type( $tag ) {
|
@@ -79,11 +100,11 @@ class WPCF7_FormTagsManager {
|
|
79 |
}
|
80 |
|
81 |
public function remove( $tag ) {
|
82 |
-
unset( $this->
|
83 |
}
|
84 |
|
85 |
public function normalize( $content ) {
|
86 |
-
if ( empty( $this->
|
87 |
return $content;
|
88 |
}
|
89 |
|
@@ -126,7 +147,7 @@ class WPCF7_FormTagsManager {
|
|
126 |
public function scan( $content, $replace = false ) {
|
127 |
$this->scanned_tags = array();
|
128 |
|
129 |
-
if ( empty( $this->
|
130 |
if ( $replace ) {
|
131 |
return $content;
|
132 |
} else {
|
@@ -151,8 +172,59 @@ class WPCF7_FormTagsManager {
|
|
151 |
}
|
152 |
}
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
private function tag_regex() {
|
155 |
-
$tagnames = array_keys( $this->
|
156 |
$tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
|
157 |
|
158 |
return '(\[?)'
|
@@ -184,11 +256,13 @@ class WPCF7_FormTagsManager {
|
|
184 |
'pipes' => null,
|
185 |
'labels' => array(),
|
186 |
'attr' => '',
|
187 |
-
'content' => ''
|
|
|
188 |
|
189 |
if ( is_array( $attr ) ) {
|
190 |
if ( is_array( $attr['options'] ) ) {
|
191 |
-
if ( $this->
|
|
|
192 |
$scanned_tag['name'] = array_shift( $attr['options'] );
|
193 |
|
194 |
if ( ! wpcf7_is_name( $scanned_tag['name'] ) ) {
|
@@ -227,7 +301,7 @@ class WPCF7_FormTagsManager {
|
|
227 |
$this->scanned_tags[] = $scanned_tag;
|
228 |
|
229 |
if ( $replace ) {
|
230 |
-
$func = $this->
|
231 |
return $m[1] . call_user_func( $func, $scanned_tag ) . $m[6];
|
232 |
} else {
|
233 |
return $m[0];
|
1 |
<?php
|
2 |
|
3 |
+
function wpcf7_add_form_tag( $tag, $func, $features = '' ) {
|
4 |
$manager = WPCF7_FormTagsManager::get_instance();
|
5 |
|
6 |
+
return $manager->add( $tag, $func, $features );
|
7 |
}
|
8 |
|
9 |
function wpcf7_remove_form_tag( $tag ) {
|
28 |
return array();
|
29 |
}
|
30 |
|
31 |
+
function wpcf7_form_tag_supports( $tag, $feature ) {
|
32 |
+
$manager = WPCF7_FormTagsManager::get_instance();
|
33 |
+
|
34 |
+
return $manager->tag_type_supports( $tag, $feature );
|
35 |
+
}
|
36 |
+
|
37 |
class WPCF7_FormTagsManager {
|
38 |
|
39 |
private static $instance;
|
40 |
|
41 |
+
private $tag_types = array();
|
42 |
private $scanned_tags = null; // Tags scanned at the last time of scan()
|
43 |
|
44 |
private function __construct() {}
|
55 |
return $this->scanned_tags;
|
56 |
}
|
57 |
|
58 |
+
public function add( $tag, $func, $features = '' ) {
|
59 |
if ( ! is_callable( $func ) ) {
|
60 |
return;
|
61 |
}
|
62 |
|
63 |
+
if ( true === $features ) { // for back-compat
|
64 |
+
$features = array( 'name-attr' => true );
|
65 |
+
}
|
66 |
+
|
67 |
+
$features = wp_parse_args( $features, array() );
|
68 |
+
|
69 |
$tags = array_filter( array_unique( (array) $tag ) );
|
70 |
|
71 |
foreach ( $tags as $tag ) {
|
72 |
$tag = $this->sanitize_tag_type( $tag );
|
73 |
|
74 |
if ( ! $this->tag_type_exists( $tag ) ) {
|
75 |
+
$this->tag_types[$tag] = array(
|
76 |
'function' => $func,
|
77 |
+
'features' => $features,
|
78 |
+
);
|
79 |
}
|
80 |
}
|
81 |
}
|
82 |
|
83 |
public function tag_type_exists( $tag ) {
|
84 |
+
return isset( $this->tag_types[$tag] );
|
85 |
+
}
|
86 |
+
|
87 |
+
public function tag_type_supports( $tag, $feature ) {
|
88 |
+
if ( isset( $this->tag_types[$tag]['features'] ) ) {
|
89 |
+
return ! empty( $this->tag_types[$tag]['features'][$feature] );
|
90 |
+
}
|
91 |
+
|
92 |
+
return false;
|
93 |
}
|
94 |
|
95 |
private function sanitize_tag_type( $tag ) {
|
100 |
}
|
101 |
|
102 |
public function remove( $tag ) {
|
103 |
+
unset( $this->tag_types[$tag] );
|
104 |
}
|
105 |
|
106 |
public function normalize( $content ) {
|
107 |
+
if ( empty( $this->tag_types ) ) {
|
108 |
return $content;
|
109 |
}
|
110 |
|
147 |
public function scan( $content, $replace = false ) {
|
148 |
$this->scanned_tags = array();
|
149 |
|
150 |
+
if ( empty( $this->tag_types ) ) {
|
151 |
if ( $replace ) {
|
152 |
return $content;
|
153 |
} else {
|
172 |
}
|
173 |
}
|
174 |
|
175 |
+
public function filter( $content, $cond ) {
|
176 |
+
if ( is_array( $content ) ) {
|
177 |
+
$tags = $content;
|
178 |
+
} elseif ( is_string( $content ) ) {
|
179 |
+
$tags = $this->scan( $content );
|
180 |
+
} else {
|
181 |
+
$tags = $this->scanned_tags;
|
182 |
+
}
|
183 |
+
|
184 |
+
if ( empty( $tags ) ) {
|
185 |
+
return array();
|
186 |
+
}
|
187 |
+
|
188 |
+
if ( ! is_array( $cond ) || empty( $cond ) ) {
|
189 |
+
return $tags;
|
190 |
+
}
|
191 |
+
|
192 |
+
for ( $i = 0, $size = count( $tags ); $i < $size; $i++ ) {
|
193 |
+
|
194 |
+
if ( isset( $cond['type'] ) ) {
|
195 |
+
if ( is_string( $cond['type'] ) && ! empty( $cond['type'] ) ) {
|
196 |
+
if ( $tags[$i]['type'] != $cond['type'] ) {
|
197 |
+
unset( $tags[$i] );
|
198 |
+
continue;
|
199 |
+
}
|
200 |
+
} elseif ( is_array( $cond['type'] ) ) {
|
201 |
+
if ( ! in_array( $tags[$i]['type'], $cond['type'] ) ) {
|
202 |
+
unset( $tags[$i] );
|
203 |
+
continue;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
if ( isset( $cond['name'] ) ) {
|
209 |
+
if ( is_string( $cond['name'] ) && ! empty( $cond['name'] ) ) {
|
210 |
+
if ( $tags[$i]['name'] != $cond['name'] ) {
|
211 |
+
unset ( $tags[$i] );
|
212 |
+
continue;
|
213 |
+
}
|
214 |
+
} elseif ( is_array( $cond['name'] ) ) {
|
215 |
+
if ( ! in_array( $tags[$i]['name'], $cond['name'] ) ) {
|
216 |
+
unset( $tags[$i] );
|
217 |
+
continue;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
return array_values( $tags );
|
224 |
+
}
|
225 |
+
|
226 |
private function tag_regex() {
|
227 |
+
$tagnames = array_keys( $this->tag_types );
|
228 |
$tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
|
229 |
|
230 |
return '(\[?)'
|
256 |
'pipes' => null,
|
257 |
'labels' => array(),
|
258 |
'attr' => '',
|
259 |
+
'content' => '',
|
260 |
+
);
|
261 |
|
262 |
if ( is_array( $attr ) ) {
|
263 |
if ( is_array( $attr['options'] ) ) {
|
264 |
+
if ( $this->tag_type_supports( $tag, 'name-attr' )
|
265 |
+
&& ! empty( $attr['options'] ) ) {
|
266 |
$scanned_tag['name'] = array_shift( $attr['options'] );
|
267 |
|
268 |
if ( ! wpcf7_is_name( $scanned_tag['name'] ) ) {
|
301 |
$this->scanned_tags[] = $scanned_tag;
|
302 |
|
303 |
if ( $replace ) {
|
304 |
+
$func = $this->tag_types[$tag]['function'];
|
305 |
return $m[1] . call_user_func( $func, $scanned_tag ) . $m[6];
|
306 |
} else {
|
307 |
return $m[0];
|
includes/formatting.php
CHANGED
@@ -219,7 +219,16 @@ function wpcf7_is_date( $date ) {
|
|
219 |
|
220 |
function wpcf7_is_mailbox_list( $mailbox_list ) {
|
221 |
if ( ! is_array( $mailbox_list ) ) {
|
222 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
224 |
|
225 |
$addresses = array();
|
@@ -314,8 +323,9 @@ function wpcf7_antiscript_file_name( $filename ) {
|
|
314 |
$filename = basename( $filename );
|
315 |
$parts = explode( '.', $filename );
|
316 |
|
317 |
-
if ( count( $parts ) < 2 )
|
318 |
return $filename;
|
|
|
319 |
|
320 |
$script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i';
|
321 |
|
@@ -323,16 +333,18 @@ function wpcf7_antiscript_file_name( $filename ) {
|
|
323 |
$extension = array_pop( $parts );
|
324 |
|
325 |
foreach ( (array) $parts as $part ) {
|
326 |
-
if ( preg_match( $script_pattern, $part ) )
|
327 |
$filename .= '.' . $part . '_';
|
328 |
-
else
|
329 |
$filename .= '.' . $part;
|
|
|
330 |
}
|
331 |
|
332 |
-
if ( preg_match( $script_pattern, $extension ) )
|
333 |
$filename .= '.' . $extension . '_.txt';
|
334 |
-
else
|
335 |
$filename .= '.' . $extension;
|
|
|
336 |
|
337 |
return $filename;
|
338 |
}
|
219 |
|
220 |
function wpcf7_is_mailbox_list( $mailbox_list ) {
|
221 |
if ( ! is_array( $mailbox_list ) ) {
|
222 |
+
$mailbox_text = (string) $mailbox_list;
|
223 |
+
$mailbox_text = wp_unslash( $mailbox_text );
|
224 |
+
|
225 |
+
$mailbox_text = preg_replace( '/\\\\(?:\"|\')/', 'esc-quote',
|
226 |
+
$mailbox_text );
|
227 |
+
|
228 |
+
$mailbox_text = preg_replace( '/(?:\".*?\"|\'.*?\')/', 'quoted-string',
|
229 |
+
$mailbox_text );
|
230 |
+
|
231 |
+
$mailbox_list = explode( ',', $mailbox_text );
|
232 |
}
|
233 |
|
234 |
$addresses = array();
|
323 |
$filename = basename( $filename );
|
324 |
$parts = explode( '.', $filename );
|
325 |
|
326 |
+
if ( count( $parts ) < 2 ) {
|
327 |
return $filename;
|
328 |
+
}
|
329 |
|
330 |
$script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i';
|
331 |
|
333 |
$extension = array_pop( $parts );
|
334 |
|
335 |
foreach ( (array) $parts as $part ) {
|
336 |
+
if ( preg_match( $script_pattern, $part ) ) {
|
337 |
$filename .= '.' . $part . '_';
|
338 |
+
} else {
|
339 |
$filename .= '.' . $part;
|
340 |
+
}
|
341 |
}
|
342 |
|
343 |
+
if ( preg_match( $script_pattern, $extension ) ) {
|
344 |
$filename .= '.' . $extension . '_.txt';
|
345 |
+
} else {
|
346 |
$filename .= '.' . $extension;
|
347 |
+
}
|
348 |
|
349 |
return $filename;
|
350 |
}
|
includes/functions.php
CHANGED
@@ -31,8 +31,9 @@ function wpcf7_upload_dir( $type = false ) {
|
|
31 |
}
|
32 |
|
33 |
function wpcf7_verify_nonce( $nonce, $action = -1 ) {
|
34 |
-
if ( substr( wp_hash( $action, 'nonce' ), -12, 10 ) == $nonce )
|
35 |
return true;
|
|
|
36 |
|
37 |
return false;
|
38 |
}
|
@@ -68,13 +69,15 @@ function wpcf7_blacklist_check( $target ) {
|
|
68 |
}
|
69 |
|
70 |
function wpcf7_array_flatten( $input ) {
|
71 |
-
if ( ! is_array( $input ) )
|
72 |
return array( $input );
|
|
|
73 |
|
74 |
$output = array();
|
75 |
|
76 |
-
foreach ( $input as $value )
|
77 |
$output = array_merge( $output, wpcf7_array_flatten( $value ) );
|
|
|
78 |
|
79 |
return $output;
|
80 |
}
|
@@ -83,8 +86,9 @@ function wpcf7_flat_join( $input ) {
|
|
83 |
$input = wpcf7_array_flatten( $input );
|
84 |
$output = array();
|
85 |
|
86 |
-
foreach ( (array) $input as $value )
|
87 |
$output[] = trim( (string) $value );
|
|
|
88 |
|
89 |
return implode( ', ', $output );
|
90 |
}
|
@@ -150,7 +154,8 @@ function wpcf7_format_atts( $atts ) {
|
|
150 |
function wpcf7_link( $url, $anchor_text, $args = '' ) {
|
151 |
$defaults = array(
|
152 |
'id' => '',
|
153 |
-
'class' => ''
|
|
|
154 |
|
155 |
$args = wp_parse_args( $args, $defaults );
|
156 |
$args = array_intersect_key( $args, $defaults );
|
@@ -228,7 +233,8 @@ function wpcf7_enctype_value( $enctype ) {
|
|
228 |
$valid_enctypes = array(
|
229 |
'application/x-www-form-urlencoded',
|
230 |
'multipart/form-data',
|
231 |
-
'text/plain'
|
|
|
232 |
|
233 |
if ( in_array( $enctype, $valid_enctypes ) ) {
|
234 |
return $enctype;
|
31 |
}
|
32 |
|
33 |
function wpcf7_verify_nonce( $nonce, $action = -1 ) {
|
34 |
+
if ( substr( wp_hash( $action, 'nonce' ), -12, 10 ) == $nonce ) {
|
35 |
return true;
|
36 |
+
}
|
37 |
|
38 |
return false;
|
39 |
}
|
69 |
}
|
70 |
|
71 |
function wpcf7_array_flatten( $input ) {
|
72 |
+
if ( ! is_array( $input ) ) {
|
73 |
return array( $input );
|
74 |
+
}
|
75 |
|
76 |
$output = array();
|
77 |
|
78 |
+
foreach ( $input as $value ) {
|
79 |
$output = array_merge( $output, wpcf7_array_flatten( $value ) );
|
80 |
+
}
|
81 |
|
82 |
return $output;
|
83 |
}
|
86 |
$input = wpcf7_array_flatten( $input );
|
87 |
$output = array();
|
88 |
|
89 |
+
foreach ( (array) $input as $value ) {
|
90 |
$output[] = trim( (string) $value );
|
91 |
+
}
|
92 |
|
93 |
return implode( ', ', $output );
|
94 |
}
|
154 |
function wpcf7_link( $url, $anchor_text, $args = '' ) {
|
155 |
$defaults = array(
|
156 |
'id' => '',
|
157 |
+
'class' => '',
|
158 |
+
);
|
159 |
|
160 |
$args = wp_parse_args( $args, $defaults );
|
161 |
$args = array_intersect_key( $args, $defaults );
|
233 |
$valid_enctypes = array(
|
234 |
'application/x-www-form-urlencoded',
|
235 |
'multipart/form-data',
|
236 |
+
'text/plain',
|
237 |
+
);
|
238 |
|
239 |
if ( in_array( $enctype, $valid_enctypes ) ) {
|
240 |
return $enctype;
|
includes/integration.php
CHANGED
@@ -55,7 +55,8 @@ class WPCF7_Integration {
|
|
55 |
|
56 |
public function list_services( $args = '' ) {
|
57 |
$args = wp_parse_args( $args, array(
|
58 |
-
'include' => array()
|
|
|
59 |
|
60 |
$singular = false;
|
61 |
$services = (array) $this->services;
|
55 |
|
56 |
public function list_services( $args = '' ) {
|
57 |
$args = wp_parse_args( $args, array(
|
58 |
+
'include' => array(),
|
59 |
+
) );
|
60 |
|
61 |
$singular = false;
|
62 |
$services = (array) $this->services;
|
includes/js/scripts.js
CHANGED
@@ -1,458 +1,507 @@
|
|
1 |
-
(function($) {
|
2 |
|
3 |
'use strict';
|
4 |
|
5 |
-
if (typeof _wpcf7
|
6 |
return;
|
7 |
}
|
8 |
|
9 |
-
_wpcf7 = $.extend({
|
10 |
-
cached: 0
|
11 |
-
|
|
|
12 |
|
13 |
$.fn.wpcf7InitForm = function() {
|
14 |
-
this.ajaxForm({
|
15 |
-
beforeSubmit: function(arr, $form, options) {
|
16 |
$form.wpcf7ClearResponseOutput();
|
17 |
-
$form.find('[aria-invalid]').attr('aria-invalid', 'false');
|
18 |
-
$form.find('.ajax-loader').addClass('is-active');
|
19 |
return true;
|
20 |
},
|
21 |
-
beforeSerialize: function($form, options) {
|
22 |
-
$form.find('[placeholder].placeheld').each(function(i, n) {
|
23 |
-
$(n).val('');
|
24 |
-
});
|
25 |
return true;
|
26 |
},
|
27 |
data: { '_wpcf7_is_ajax_call': 1 },
|
28 |
dataType: 'json',
|
29 |
success: $.wpcf7AjaxSuccess,
|
30 |
-
error: function(xhr, status, error, $form) {
|
31 |
-
var e = $('<div class="ajax-error"></div>').text(error.message);
|
32 |
-
$form.after(e);
|
33 |
}
|
34 |
-
});
|
35 |
|
36 |
-
if (_wpcf7.cached) {
|
37 |
this.wpcf7OnloadRefill();
|
38 |
}
|
39 |
|
40 |
this.wpcf7ToggleSubmit();
|
41 |
|
42 |
-
this.find('.wpcf7-submit').wpcf7AjaxLoader();
|
43 |
|
44 |
-
this.find('.wpcf7-acceptance').click(function() {
|
45 |
-
$(this).closest('form').wpcf7ToggleSubmit();
|
46 |
-
});
|
47 |
|
48 |
-
this.find('.wpcf7-exclusive-checkbox').wpcf7ExclusiveCheckbox();
|
49 |
|
50 |
-
this.find('.wpcf7-list-item.has-free-text').wpcf7ToggleCheckboxFreetext();
|
51 |
|
52 |
-
this.find('[placeholder]').wpcf7Placeholder();
|
53 |
|
54 |
-
if (_wpcf7.jqueryUi && ! _wpcf7.supportHtml5.date) {
|
55 |
-
this.find('input.wpcf7-date[type="date"]').each(function() {
|
56 |
-
$(this).datepicker({
|
57 |
dateFormat: 'yy-mm-dd',
|
58 |
-
minDate: new Date($(this).attr('min')),
|
59 |
-
maxDate: new Date($(this).attr('max'))
|
60 |
-
});
|
61 |
-
});
|
62 |
}
|
63 |
|
64 |
-
if (_wpcf7.jqueryUi && ! _wpcf7.supportHtml5.number) {
|
65 |
-
this.find('input.wpcf7-number[type="number"]').each(function() {
|
66 |
-
$(this).spinner({
|
67 |
-
min: $(this).attr('min'),
|
68 |
-
max: $(this).attr('max'),
|
69 |
-
step: $(this).attr('step')
|
70 |
-
});
|
71 |
-
});
|
72 |
}
|
73 |
|
74 |
-
this.find('.wpcf7-character-count').wpcf7CharacterCount();
|
75 |
|
76 |
-
this.find('.wpcf7-validates-as-url').change(function() {
|
77 |
-
$(this).wpcf7NormalizeUrl();
|
78 |
-
});
|
79 |
|
80 |
-
this.find('.wpcf7-recaptcha').wpcf7Recaptcha();
|
81 |
};
|
82 |
|
83 |
-
$.wpcf7AjaxSuccess = function(data, status, xhr, $form) {
|
84 |
-
if (! $.isPlainObject(data) || $.isEmptyObject(data)) {
|
85 |
return;
|
86 |
}
|
87 |
|
88 |
-
|
|
|
|
|
89 |
|
90 |
$form.wpcf7ClearResponseOutput();
|
91 |
|
92 |
-
$form.find('.wpcf7-form-control').removeClass('wpcf7-not-valid');
|
93 |
-
$form.removeClass('invalid spam sent failed');
|
94 |
|
95 |
-
if (data.captcha) {
|
96 |
-
$form.wpcf7RefillCaptcha(data.captcha);
|
97 |
}
|
98 |
|
99 |
-
if (data.quiz) {
|
100 |
-
$form.wpcf7RefillQuiz(data.quiz);
|
101 |
}
|
102 |
|
103 |
-
if (data.invalids) {
|
104 |
-
$.each(data.invalids, function(i, n) {
|
105 |
-
$form.find(n.into).wpcf7NotValidTip(n.message);
|
106 |
-
$form.find(n.into).find('.wpcf7-form-control').addClass('wpcf7-not-valid');
|
107 |
-
$form.find(n.into).find('[aria-invalid]').attr('aria-invalid', 'true');
|
108 |
-
});
|
109 |
|
110 |
-
$responseOutput.addClass('wpcf7-validation-errors');
|
111 |
-
$form.addClass('invalid');
|
112 |
|
113 |
-
$(data.into).
|
114 |
-
$(data.into).trigger('invalid.wpcf7'); // deprecated
|
115 |
|
116 |
-
} else if (1 == data.spam) {
|
117 |
-
$form.find('[name="g-recaptcha-response"]').each(function() {
|
118 |
-
if ('' == $(this).val()) {
|
119 |
-
var $recaptcha = $(this).closest('.wpcf7-form-control-wrap');
|
120 |
-
$recaptcha.wpcf7NotValidTip(_wpcf7.recaptcha.messages.empty);
|
121 |
}
|
122 |
-
});
|
123 |
|
124 |
-
$responseOutput.addClass('wpcf7-spam-blocked');
|
125 |
-
$form.addClass('spam');
|
126 |
|
127 |
-
$(data.into).
|
128 |
-
$(data.into).trigger('spam.wpcf7'); // deprecated
|
129 |
|
130 |
-
} else if (1 == data.mailSent) {
|
131 |
-
$responseOutput.addClass('wpcf7-mail-sent-ok');
|
132 |
-
$form.addClass('sent');
|
133 |
|
134 |
-
if (data.onSentOk) {
|
135 |
-
$.each(data.onSentOk, function(i, n) { eval(n) });
|
136 |
}
|
137 |
|
138 |
-
$(data.into).
|
139 |
-
$(data.into).trigger('mailsent.wpcf7'); // deprecated
|
140 |
|
141 |
} else {
|
142 |
-
$responseOutput.addClass('wpcf7-mail-sent-ng');
|
143 |
-
$form.addClass('failed');
|
144 |
|
145 |
-
$(data.into).
|
146 |
-
$(data.into).trigger('mailfailed.wpcf7'); // deprecated
|
147 |
}
|
148 |
|
149 |
-
if (data.onSubmit) {
|
150 |
-
$.each(data.onSubmit, function(i, n) { eval(n) });
|
151 |
}
|
152 |
|
153 |
-
$(data.into).
|
154 |
-
$(data.into).trigger('submit.wpcf7'); // deprecated
|
155 |
|
156 |
-
if (1 == data.mailSent) {
|
157 |
$form.resetForm();
|
158 |
}
|
159 |
|
160 |
-
$form.find('[placeholder].placeheld').each(function(i, n) {
|
161 |
-
$(n).val($(n).attr('placeholder'));
|
162 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
-
|
165 |
-
$responseOutput.attr('role', 'alert');
|
166 |
|
167 |
-
|
|
|
|
|
|
|
168 |
};
|
169 |
|
170 |
$.fn.wpcf7ExclusiveCheckbox = function() {
|
171 |
-
return this.find('input:checkbox').click(function() {
|
172 |
-
var name = $(this).attr('name');
|
173 |
-
$(this).closest('form').find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false);
|
174 |
-
});
|
175 |
};
|
176 |
|
177 |
$.fn.wpcf7Placeholder = function() {
|
178 |
-
if (_wpcf7.supportHtml5.placeholder) {
|
179 |
return this;
|
180 |
}
|
181 |
|
182 |
-
return this.each(function() {
|
183 |
-
$(this).val($(this).attr('placeholder'));
|
184 |
-
$(this).addClass('placeheld');
|
185 |
|
186 |
-
$(this).focus(function() {
|
187 |
-
if ($(this).hasClass('placeheld'))
|
188 |
-
$(this).val('').removeClass('placeheld');
|
189 |
-
|
|
|
190 |
|
191 |
-
$(this).blur(function() {
|
192 |
-
if (''
|
193 |
-
$(this).val($(this).attr('placeholder'));
|
194 |
-
$(this).addClass('placeheld');
|
195 |
}
|
196 |
-
});
|
197 |
-
});
|
198 |
};
|
199 |
|
200 |
$.fn.wpcf7AjaxLoader = function() {
|
201 |
-
return this.each(function() {
|
202 |
-
$(this).after('<span class="ajax-loader"></span>');
|
203 |
-
});
|
204 |
};
|
205 |
|
206 |
$.fn.wpcf7ToggleSubmit = function() {
|
207 |
-
return this.each(function() {
|
208 |
-
var form = $(this);
|
|
|
|
|
|
|
|
|
209 |
|
210 |
-
if (
|
211 |
-
|
212 |
}
|
213 |
|
214 |
-
|
|
|
|
|
215 |
return;
|
216 |
}
|
217 |
|
218 |
-
var
|
219 |
-
|
|
|
|
|
|
|
220 |
|
221 |
-
|
222 |
-
|
|
|
223 |
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
if (n.hasClass('wpcf7-invert') && n.is(':checked')
|
228 |
-
|| ! n.hasClass('wpcf7-invert') && ! n.is(':checked')) {
|
229 |
-
submit.attr('disabled', 'disabled');
|
230 |
}
|
231 |
-
});
|
232 |
-
});
|
233 |
};
|
234 |
|
235 |
$.fn.wpcf7ToggleCheckboxFreetext = function() {
|
236 |
-
return this.each(function() {
|
237 |
-
var $wrap = $(this).closest('.wpcf7-form-control');
|
238 |
|
239 |
-
if ($(this).find(':checkbox, :radio').is(':checked')) {
|
240 |
-
$(this).find(':input.wpcf7-free-text').prop('disabled', false);
|
241 |
} else {
|
242 |
-
$(this).find(':input.wpcf7-free-text').prop('disabled', true);
|
243 |
}
|
244 |
|
245 |
-
$wrap.find(':checkbox, :radio').change(function() {
|
246 |
-
var $cb = $('.has-free-text', $wrap).find(':checkbox, :radio');
|
247 |
-
var $freetext = $(':input.wpcf7-free-text', $wrap);
|
248 |
|
249 |
-
if ($cb.is(':checked')) {
|
250 |
-
$freetext.prop('disabled', false).focus();
|
251 |
} else {
|
252 |
-
$freetext.prop('disabled', true);
|
253 |
}
|
254 |
-
});
|
255 |
-
});
|
256 |
};
|
257 |
|
258 |
$.fn.wpcf7CharacterCount = function() {
|
259 |
-
return this.each(function() {
|
260 |
-
var $count = $(this);
|
261 |
-
var name = $count.attr('data-target-name');
|
262 |
-
var down = $count.hasClass('down');
|
263 |
-
var starting = parseInt($count.attr('data-starting-value'), 10);
|
264 |
-
var maximum = parseInt($count.attr('data-maximum-value'), 10);
|
265 |
-
var minimum = parseInt($count.attr('data-minimum-value'), 10);
|
266 |
-
|
267 |
-
var updateCount = function($target) {
|
268 |
var length = $target.val().length;
|
269 |
var count = down ? starting - length : length;
|
270 |
-
$count.attr('data-current-value', count);
|
271 |
-
$count.text(count);
|
272 |
|
273 |
-
if (maximum && maximum < length) {
|
274 |
-
$count.addClass('too-long');
|
275 |
} else {
|
276 |
-
$count.removeClass('too-long');
|
277 |
}
|
278 |
|
279 |
-
if (minimum && length < minimum) {
|
280 |
-
$count.addClass('too-short');
|
281 |
} else {
|
282 |
-
$count.removeClass('too-short');
|
283 |
}
|
284 |
};
|
285 |
|
286 |
-
$count.closest('form').find(':input[name="' + name + '"]').each(function() {
|
287 |
-
updateCount($(this));
|
288 |
|
289 |
-
$(this).keyup(function() {
|
290 |
-
updateCount($(this));
|
291 |
-
});
|
292 |
-
});
|
293 |
-
});
|
294 |
};
|
295 |
|
296 |
$.fn.wpcf7NormalizeUrl = function() {
|
297 |
-
return this.each(function() {
|
298 |
-
var val = $.trim($(this).val());
|
299 |
|
300 |
-
|
301 |
-
|
|
|
302 |
val = 'http://' + val;
|
303 |
}
|
304 |
|
305 |
-
$(this).val(val);
|
306 |
-
});
|
307 |
};
|
308 |
|
309 |
-
$.fn.wpcf7NotValidTip = function(message) {
|
310 |
-
return this.each(function() {
|
311 |
-
var $into = $(this);
|
312 |
|
313 |
-
$into.find('span.wpcf7-not-valid-tip').remove();
|
314 |
-
$into.append('<span role="alert" class="wpcf7-not-valid-tip">' + message + '</span>');
|
315 |
|
316 |
-
if ($into.is('.use-floating-validation-tip *')) {
|
317 |
-
$('.wpcf7-not-valid-tip', $into).mouseover(function() {
|
318 |
-
$(this).wpcf7FadeOut();
|
319 |
-
});
|
320 |
|
321 |
-
$(':input', $into).focus(function() {
|
322 |
-
$('.wpcf7-not-valid-tip', $into).not(':hidden').wpcf7FadeOut();
|
323 |
-
});
|
324 |
}
|
325 |
-
});
|
326 |
};
|
327 |
|
328 |
$.fn.wpcf7FadeOut = function() {
|
329 |
-
return this.each(function() {
|
330 |
-
$(this).animate({
|
331 |
opacity: 0
|
332 |
}, 'fast', function() {
|
333 |
-
$(this).css({'z-index': -100});
|
334 |
-
});
|
335 |
-
});
|
336 |
};
|
337 |
|
338 |
$.fn.wpcf7OnloadRefill = function() {
|
339 |
-
return this.each(function() {
|
340 |
-
var url = $(this).attr('action');
|
341 |
|
342 |
-
if (0 < url.indexOf('#')) {
|
343 |
-
url = url.substr(0, url.indexOf('#'));
|
344 |
}
|
345 |
|
346 |
-
var id = $(this).find('input[name="_wpcf7"]').val();
|
347 |
-
var unitTag = $(this).find('input[name="_wpcf7_unit_tag"]').val();
|
348 |
|
349 |
-
$.getJSON(url,
|
350 |
{ _wpcf7_is_ajax_call: 1, _wpcf7: id, _wpcf7_request_ver: $.now() },
|
351 |
-
function(data) {
|
352 |
-
if (data && data.captcha) {
|
353 |
-
$('#' + unitTag).wpcf7RefillCaptcha(data.captcha);
|
354 |
}
|
355 |
|
356 |
-
if (data && data.quiz) {
|
357 |
-
$('#' + unitTag).wpcf7RefillQuiz(data.quiz);
|
358 |
}
|
359 |
}
|
360 |
);
|
361 |
-
});
|
362 |
};
|
363 |
|
364 |
-
$.fn.wpcf7RefillCaptcha = function(captcha) {
|
365 |
-
return this.each(function() {
|
366 |
-
var form = $(this);
|
367 |
-
|
368 |
-
$.each(captcha, function(i, n) {
|
369 |
-
form.find(':input[name="' + i + '"]').clearFields();
|
370 |
-
form.find('img.wpcf7-captcha-' + i).attr('src', n);
|
371 |
-
var match = /([0-9]+)\.(png|gif|jpeg)$/.exec(n);
|
372 |
-
form.find('input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]').attr('value', match[1]);
|
373 |
-
});
|
374 |
-
});
|
375 |
};
|
376 |
|
377 |
-
$.fn.wpcf7RefillQuiz = function(quiz) {
|
378 |
-
return this.each(function() {
|
379 |
-
var form = $(this);
|
380 |
|
381 |
-
$.each(quiz, function(i, n) {
|
382 |
-
form.find(':input[name="' + i + '"]').clearFields();
|
383 |
-
form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[0]);
|
384 |
-
form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[1]);
|
385 |
-
});
|
386 |
-
});
|
387 |
};
|
388 |
|
389 |
$.fn.wpcf7ClearResponseOutput = function() {
|
390 |
-
return this.each(function() {
|
391 |
-
$(this).find('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked').removeAttr('role');
|
392 |
-
$(this).find('span.wpcf7-not-valid-tip').remove();
|
393 |
-
$(this).find('.ajax-loader').removeClass('is-active');
|
394 |
-
});
|
395 |
};
|
396 |
|
397 |
$.fn.wpcf7Recaptcha = function() {
|
398 |
-
return this.each(function() {
|
399 |
var events = 'wpcf7:spam wpcf7:mailsent wpcf7:mailfailed';
|
400 |
-
$(this).closest('div.wpcf7').on(events, function(e) {
|
401 |
-
if (recaptchaWidgets && grecaptcha) {
|
402 |
-
$.each(recaptchaWidgets, function(index, value) {
|
403 |
-
grecaptcha.reset(value);
|
404 |
-
});
|
405 |
}
|
406 |
-
});
|
407 |
-
});
|
408 |
};
|
409 |
|
410 |
-
$.wpcf7UpdateScreenReaderResponse = function($form, data) {
|
411 |
-
$('.wpcf7 .screen-reader-response').html('').attr('role', '');
|
412 |
|
413 |
-
if (data.message) {
|
414 |
-
var $response = $form.siblings('.screen-reader-response').first();
|
415 |
-
$response.append(data.message);
|
416 |
|
417 |
-
if (data.invalids) {
|
418 |
-
var $invalids = $('<ul></ul>');
|
419 |
|
420 |
-
$.each(data.invalids, function(i, n) {
|
421 |
-
if (n.idref) {
|
422 |
-
var $li = $('<li></li>').append($('<a></a>').attr('href', '#' + n.idref).append(n.message));
|
423 |
} else {
|
424 |
-
var $li = $('<li></li>').append(n.message);
|
425 |
}
|
426 |
|
427 |
-
$invalids.append($li);
|
428 |
-
});
|
429 |
|
430 |
-
$response.append($invalids);
|
431 |
}
|
432 |
|
433 |
-
$response.attr('role', 'alert').focus();
|
434 |
}
|
435 |
};
|
436 |
|
437 |
$.wpcf7SupportHtml5 = function() {
|
438 |
var features = {};
|
439 |
-
var input = document.createElement('input');
|
440 |
|
441 |
features.placeholder = 'placeholder' in input;
|
442 |
|
443 |
-
var inputTypes = ['email', 'url', 'tel', 'number', 'range', 'date'];
|
444 |
|
445 |
-
$.each(inputTypes, function(index, value) {
|
446 |
-
input.setAttribute('type', value);
|
447 |
-
features[value] = input.type !== 'text';
|
448 |
-
});
|
449 |
|
450 |
return features;
|
451 |
};
|
452 |
|
453 |
-
$(function() {
|
454 |
_wpcf7.supportHtml5 = $.wpcf7SupportHtml5();
|
455 |
-
$('div.wpcf7 > form').wpcf7InitForm();
|
456 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
|
458 |
-
|
|
1 |
+
( function( $ ) {
|
2 |
|
3 |
'use strict';
|
4 |
|
5 |
+
if ( typeof _wpcf7 === 'undefined' || _wpcf7 === null ) {
|
6 |
return;
|
7 |
}
|
8 |
|
9 |
+
_wpcf7 = $.extend( {
|
10 |
+
cached: 0,
|
11 |
+
inputs: []
|
12 |
+
}, _wpcf7 );
|
13 |
|
14 |
$.fn.wpcf7InitForm = function() {
|
15 |
+
this.ajaxForm( {
|
16 |
+
beforeSubmit: function( arr, $form, options ) {
|
17 |
$form.wpcf7ClearResponseOutput();
|
18 |
+
$form.find( '[aria-invalid]' ).attr( 'aria-invalid', 'false' );
|
19 |
+
$form.find( '.ajax-loader' ).addClass( 'is-active' );
|
20 |
return true;
|
21 |
},
|
22 |
+
beforeSerialize: function( $form, options ) {
|
23 |
+
$form.find( '[placeholder].placeheld' ).each( function( i, n ) {
|
24 |
+
$( n ).val( '' );
|
25 |
+
} );
|
26 |
return true;
|
27 |
},
|
28 |
data: { '_wpcf7_is_ajax_call': 1 },
|
29 |
dataType: 'json',
|
30 |
success: $.wpcf7AjaxSuccess,
|
31 |
+
error: function( xhr, status, error, $form ) {
|
32 |
+
var e = $( '<div class="ajax-error"></div>' ).text( error.message );
|
33 |
+
$form.after( e );
|
34 |
}
|
35 |
+
} );
|
36 |
|
37 |
+
if ( _wpcf7.cached ) {
|
38 |
this.wpcf7OnloadRefill();
|
39 |
}
|
40 |
|
41 |
this.wpcf7ToggleSubmit();
|
42 |
|
43 |
+
this.find( '.wpcf7-submit' ).wpcf7AjaxLoader();
|
44 |
|
45 |
+
this.find( '.wpcf7-acceptance' ).click( function() {
|
46 |
+
$( this ).closest( 'form' ).wpcf7ToggleSubmit();
|
47 |
+
} );
|
48 |
|
49 |
+
this.find( '.wpcf7-exclusive-checkbox' ).wpcf7ExclusiveCheckbox();
|
50 |
|
51 |
+
this.find( '.wpcf7-list-item.has-free-text' ).wpcf7ToggleCheckboxFreetext();
|
52 |
|
53 |
+
this.find( '[placeholder]' ).wpcf7Placeholder();
|
54 |
|
55 |
+
if ( _wpcf7.jqueryUi && ! _wpcf7.supportHtml5.date ) {
|
56 |
+
this.find( 'input.wpcf7-date[type="date"]' ).each( function() {
|
57 |
+
$( this ).datepicker( {
|
58 |
dateFormat: 'yy-mm-dd',
|
59 |
+
minDate: new Date( $( this ).attr( 'min' ) ),
|
60 |
+
maxDate: new Date( $( this ).attr( 'max' ) )
|
61 |
+
} );
|
62 |
+
} );
|
63 |
}
|
64 |
|
65 |
+
if ( _wpcf7.jqueryUi && ! _wpcf7.supportHtml5.number ) {
|
66 |
+
this.find( 'input.wpcf7-number[type="number"]' ).each( function() {
|
67 |
+
$( this ).spinner( {
|
68 |
+
min: $( this ).attr( 'min' ),
|
69 |
+
max: $( this ).attr( 'max' ),
|
70 |
+
step: $( this ).attr( 'step' )
|
71 |
+
} );
|
72 |
+
} );
|
73 |
}
|
74 |
|
75 |
+
this.find( '.wpcf7-character-count' ).wpcf7CharacterCount();
|
76 |
|
77 |
+
this.find( '.wpcf7-validates-as-url' ).change( function() {
|
78 |
+
$( this ).wpcf7NormalizeUrl();
|
79 |
+
} );
|
80 |
|
81 |
+
this.find( '.wpcf7-recaptcha' ).wpcf7Recaptcha();
|
82 |
};
|
83 |
|
84 |
+
$.wpcf7AjaxSuccess = function( data, status, xhr, $form ) {
|
85 |
+
if ( ! $.isPlainObject( data ) || $.isEmptyObject( data ) ) {
|
86 |
return;
|
87 |
}
|
88 |
|
89 |
+
_wpcf7.inputs = $form.serializeArray();
|
90 |
+
|
91 |
+
var $responseOutput = $form.find( 'div.wpcf7-response-output' );
|
92 |
|
93 |
$form.wpcf7ClearResponseOutput();
|
94 |
|
95 |
+
$form.find( '.wpcf7-form-control' ).removeClass( 'wpcf7-not-valid' );
|
96 |
+
$form.removeClass( 'invalid spam sent failed' );
|
97 |
|
98 |
+
if ( data.captcha ) {
|
99 |
+
$form.wpcf7RefillCaptcha( data.captcha );
|
100 |
}
|
101 |
|
102 |
+
if ( data.quiz ) {
|
103 |
+
$form.wpcf7RefillQuiz( data.quiz );
|
104 |
}
|
105 |
|
106 |
+
if ( data.invalids ) {
|
107 |
+
$.each( data.invalids, function( i, n ) {
|
108 |
+
$form.find( n.into ).wpcf7NotValidTip( n.message );
|
109 |
+
$form.find( n.into ).find( '.wpcf7-form-control' ).addClass( 'wpcf7-not-valid' );
|
110 |
+
$form.find( n.into ).find( '[aria-invalid]' ).attr( 'aria-invalid', 'true' );
|
111 |
+
} );
|
112 |
|
113 |
+
$responseOutput.addClass( 'wpcf7-validation-errors' );
|
114 |
+
$form.addClass( 'invalid' );
|
115 |
|
116 |
+
$( data.into ).wpcf7TriggerEvent( 'invalid' );
|
|
|
117 |
|
118 |
+
} else if ( 1 == data.spam ) {
|
119 |
+
$form.find( '[name="g-recaptcha-response"]' ).each( function() {
|
120 |
+
if ( '' == $( this ).val() ) {
|
121 |
+
var $recaptcha = $( this ).closest( '.wpcf7-form-control-wrap' );
|
122 |
+
$recaptcha.wpcf7NotValidTip( _wpcf7.recaptcha.messages.empty );
|
123 |
}
|
124 |
+
} );
|
125 |
|
126 |
+
$responseOutput.addClass( 'wpcf7-spam-blocked' );
|
127 |
+
$form.addClass( 'spam' );
|
128 |
|
129 |
+
$( data.into ).wpcf7TriggerEvent( 'spam' );
|
|
|
130 |
|
131 |
+
} else if ( 1 == data.mailSent ) {
|
132 |
+
$responseOutput.addClass( 'wpcf7-mail-sent-ok' );
|
133 |
+
$form.addClass( 'sent' );
|
134 |
|
135 |
+
if ( data.onSentOk ) {
|
136 |
+
$.each( data.onSentOk, function( i, n ) { eval( n ) } );
|
137 |
}
|
138 |
|
139 |
+
$( data.into ).wpcf7TriggerEvent( 'mailsent' );
|
|
|
140 |
|
141 |
} else {
|
142 |
+
$responseOutput.addClass( 'wpcf7-mail-sent-ng' );
|
143 |
+
$form.addClass( 'failed' );
|
144 |
|
145 |
+
$( data.into ).wpcf7TriggerEvent( 'mailfailed' );
|
|
|
146 |
}
|
147 |
|
148 |
+
if ( data.onSubmit ) {
|
149 |
+
$.each( data.onSubmit, function( i, n ) { eval( n ) } );
|
150 |
}
|
151 |
|
152 |
+
$( data.into ).wpcf7TriggerEvent( 'submit' );
|
|
|
153 |
|
154 |
+
if ( 1 == data.mailSent ) {
|
155 |
$form.resetForm();
|
156 |
}
|
157 |
|
158 |
+
$form.find( '[placeholder].placeheld' ).each( function( i, n ) {
|
159 |
+
$( n ).val( $( n ).attr( 'placeholder' ) );
|
160 |
+
} );
|
161 |
+
|
162 |
+
$responseOutput.append( data.message ).slideDown( 'fast' );
|
163 |
+
$responseOutput.attr( 'role', 'alert' );
|
164 |
+
|
165 |
+
$.wpcf7UpdateScreenReaderResponse( $form, data );
|
166 |
+
};
|
167 |
+
|
168 |
+
$.fn.wpcf7TriggerEvent = function( name ) {
|
169 |
+
return this.each( function() {
|
170 |
+
var elmId = this.id;
|
171 |
+
var inputs = _wpcf7.inputs;
|
172 |
+
|
173 |
+
/* DOM event */
|
174 |
+
var event = new CustomEvent( 'wpcf7' + name, {
|
175 |
+
bubbles: true,
|
176 |
+
detail: {
|
177 |
+
id: elmId,
|
178 |
+
inputs: inputs
|
179 |
+
}
|
180 |
+
} );
|
181 |
|
182 |
+
this.dispatchEvent( event );
|
|
|
183 |
|
184 |
+
/* jQuery event */
|
185 |
+
$( this ).trigger( 'wpcf7:' + name );
|
186 |
+
$( this ).trigger( name + '.wpcf7' ); // deprecated
|
187 |
+
} );
|
188 |
};
|
189 |
|
190 |
$.fn.wpcf7ExclusiveCheckbox = function() {
|
191 |
+
return this.find( 'input:checkbox' ).click( function() {
|
192 |
+
var name = $( this ).attr( 'name' );
|
193 |
+
$( this ).closest( 'form' ).find( 'input:checkbox[name="' + name + '"]' ).not( this ).prop( 'checked', false );
|
194 |
+
} );
|
195 |
};
|
196 |
|
197 |
$.fn.wpcf7Placeholder = function() {
|
198 |
+
if ( _wpcf7.supportHtml5.placeholder ) {
|
199 |
return this;
|
200 |
}
|
201 |
|
202 |
+
return this.each( function() {
|
203 |
+
$( this ).val( $( this ).attr( 'placeholder' ) );
|
204 |
+
$( this ).addClass( 'placeheld' );
|
205 |
|
206 |
+
$( this ).focus( function() {
|
207 |
+
if ( $( this ).hasClass( 'placeheld' ) ) {
|
208 |
+
$( this ).val( '' ).removeClass( 'placeheld' );
|
209 |
+
}
|
210 |
+
} );
|
211 |
|
212 |
+
$( this ).blur( function() {
|
213 |
+
if ( '' === $( this ).val() ) {
|
214 |
+
$( this ).val( $( this ).attr( 'placeholder' ) );
|
215 |
+
$( this ).addClass( 'placeheld' );
|
216 |
}
|
217 |
+
} );
|
218 |
+
} );
|
219 |
};
|
220 |
|
221 |
$.fn.wpcf7AjaxLoader = function() {
|
222 |
+
return this.each( function() {
|
223 |
+
$( this ).after( '<span class="ajax-loader"></span>' );
|
224 |
+
} );
|
225 |
};
|
226 |
|
227 |
$.fn.wpcf7ToggleSubmit = function() {
|
228 |
+
return this.each( function() {
|
229 |
+
var form = $( this );
|
230 |
+
|
231 |
+
if ( this.tagName.toLowerCase() != 'form' ) {
|
232 |
+
form = $( this ).find( 'form' ).first();
|
233 |
+
}
|
234 |
|
235 |
+
if ( form.hasClass( 'wpcf7-acceptance-as-validation' ) ) {
|
236 |
+
return;
|
237 |
}
|
238 |
|
239 |
+
var submit = form.find( 'input:submit' );
|
240 |
+
|
241 |
+
if ( ! submit.length ) {
|
242 |
return;
|
243 |
}
|
244 |
|
245 |
+
var acceptances = form.find( 'input:checkbox.wpcf7-acceptance' );
|
246 |
+
|
247 |
+
if ( ! acceptances.length ) {
|
248 |
+
return;
|
249 |
+
}
|
250 |
|
251 |
+
submit.removeAttr( 'disabled' );
|
252 |
+
acceptances.each( function( i, n ) {
|
253 |
+
n = $( n );
|
254 |
|
255 |
+
if ( n.hasClass( 'wpcf7-invert' ) && n.is( ':checked' )
|
256 |
+
|| ! n.hasClass( 'wpcf7-invert' ) && ! n.is( ':checked' ) ) {
|
257 |
+
submit.attr( 'disabled', 'disabled' );
|
|
|
|
|
|
|
258 |
}
|
259 |
+
} );
|
260 |
+
} );
|
261 |
};
|
262 |
|
263 |
$.fn.wpcf7ToggleCheckboxFreetext = function() {
|
264 |
+
return this.each( function() {
|
265 |
+
var $wrap = $( this ).closest( '.wpcf7-form-control' );
|
266 |
|
267 |
+
if ( $( this ).find( ':checkbox, :radio' ).is( ':checked' ) ) {
|
268 |
+
$( this ).find( ':input.wpcf7-free-text' ).prop( 'disabled', false );
|
269 |
} else {
|
270 |
+
$( this ).find( ':input.wpcf7-free-text' ).prop( 'disabled', true );
|
271 |
}
|
272 |
|
273 |
+
$wrap.find( ':checkbox, :radio' ).change( function() {
|
274 |
+
var $cb = $( '.has-free-text', $wrap ).find( ':checkbox, :radio' );
|
275 |
+
var $freetext = $( ':input.wpcf7-free-text', $wrap );
|
276 |
|
277 |
+
if ( $cb.is( ':checked' ) ) {
|
278 |
+
$freetext.prop( 'disabled', false ).focus();
|
279 |
} else {
|
280 |
+
$freetext.prop( 'disabled', true );
|
281 |
}
|
282 |
+
} );
|
283 |
+
} );
|
284 |
};
|
285 |
|
286 |
$.fn.wpcf7CharacterCount = function() {
|
287 |
+
return this.each( function() {
|
288 |
+
var $count = $( this );
|
289 |
+
var name = $count.attr( 'data-target-name' );
|
290 |
+
var down = $count.hasClass( 'down' );
|
291 |
+
var starting = parseInt( $count.attr( 'data-starting-value' ), 10 );
|
292 |
+
var maximum = parseInt( $count.attr( 'data-maximum-value' ), 10 );
|
293 |
+
var minimum = parseInt( $count.attr( 'data-minimum-value' ), 10 );
|
294 |
+
|
295 |
+
var updateCount = function( $target ) {
|
296 |
var length = $target.val().length;
|
297 |
var count = down ? starting - length : length;
|
298 |
+
$count.attr( 'data-current-value', count );
|
299 |
+
$count.text( count );
|
300 |
|
301 |
+
if ( maximum && maximum < length ) {
|
302 |
+
$count.addClass( 'too-long' );
|
303 |
} else {
|
304 |
+
$count.removeClass( 'too-long' );
|
305 |
}
|
306 |
|
307 |
+
if ( minimum && length < minimum ) {
|
308 |
+
$count.addClass( 'too-short' );
|
309 |
} else {
|
310 |
+
$count.removeClass( 'too-short' );
|
311 |
}
|
312 |
};
|
313 |
|
314 |
+
$count.closest( 'form' ).find( ':input[name="' + name + '"]' ).each( function() {
|
315 |
+
updateCount( $( this ) );
|
316 |
|
317 |
+
$( this ).keyup( function() {
|
318 |
+
updateCount( $( this ) );
|
319 |
+
} );
|
320 |
+
} );
|
321 |
+
} );
|
322 |
};
|
323 |
|
324 |
$.fn.wpcf7NormalizeUrl = function() {
|
325 |
+
return this.each( function() {
|
326 |
+
var val = $.trim( $( this ).val() );
|
327 |
|
328 |
+
// check the scheme part
|
329 |
+
if ( val && ! val.match( /^[a-z][a-z0-9.+-]*:/i ) ) {
|
330 |
+
val = val.replace( /^\/+/, '' );
|
331 |
val = 'http://' + val;
|
332 |
}
|
333 |
|
334 |
+
$( this ).val( val );
|
335 |
+
} );
|
336 |
};
|
337 |
|
338 |
+
$.fn.wpcf7NotValidTip = function( message ) {
|
339 |
+
return this.each( function() {
|
340 |
+
var $into = $( this );
|
341 |
|
342 |
+
$into.find( 'span.wpcf7-not-valid-tip' ).remove();
|
343 |
+
$into.append( '<span role="alert" class="wpcf7-not-valid-tip">' + message + '</span>' );
|
344 |
|
345 |
+
if ( $into.is( '.use-floating-validation-tip *' ) ) {
|
346 |
+
$( '.wpcf7-not-valid-tip', $into ).mouseover( function() {
|
347 |
+
$( this ).wpcf7FadeOut();
|
348 |
+
} );
|
349 |
|
350 |
+
$( ':input', $into ).focus( function() {
|
351 |
+
$( '.wpcf7-not-valid-tip', $into ).not( ':hidden' ).wpcf7FadeOut();
|
352 |
+
} );
|
353 |
}
|
354 |
+
} );
|
355 |
};
|
356 |
|
357 |
$.fn.wpcf7FadeOut = function() {
|
358 |
+
return this.each( function() {
|
359 |
+
$( this ).animate( {
|
360 |
opacity: 0
|
361 |
}, 'fast', function() {
|
362 |
+
$( this ).css( { 'z-index': -100 } );
|
363 |
+
} );
|
364 |
+
} );
|
365 |
};
|
366 |
|
367 |
$.fn.wpcf7OnloadRefill = function() {
|
368 |
+
return this.each( function() {
|
369 |
+
var url = $( this ).attr( 'action' );
|
370 |
|
371 |
+
if ( 0 < url.indexOf( '#' ) ) {
|
372 |
+
url = url.substr( 0, url.indexOf( '#' ) );
|
373 |
}
|
374 |
|
375 |
+
var id = $( this ).find( 'input[name="_wpcf7"]' ).val();
|
376 |
+
var unitTag = $( this ).find( 'input[name="_wpcf7_unit_tag"]' ).val();
|
377 |
|
378 |
+
$.getJSON( url,
|
379 |
{ _wpcf7_is_ajax_call: 1, _wpcf7: id, _wpcf7_request_ver: $.now() },
|
380 |
+
function( data ) {
|
381 |
+
if ( data && data.captcha ) {
|
382 |
+
$( '#' + unitTag ).wpcf7RefillCaptcha( data.captcha );
|
383 |
}
|
384 |
|
385 |
+
if ( data && data.quiz ) {
|
386 |
+
$( '#' + unitTag ).wpcf7RefillQuiz( data.quiz );
|
387 |
}
|
388 |
}
|
389 |
);
|
390 |
+
} );
|
391 |
};
|
392 |
|
393 |
+
$.fn.wpcf7RefillCaptcha = function( captcha ) {
|
394 |
+
return this.each( function() {
|
395 |
+
var form = $( this );
|
396 |
+
|
397 |
+
$.each( captcha, function( i, n ) {
|
398 |
+
form.find( ':input[name="' + i + '"]' ).clearFields();
|
399 |
+
form.find( 'img.wpcf7-captcha-' + i ).attr( 'src', n );
|
400 |
+
var match = /([0-9]+)\.(png|gif|jpeg)$/.exec( n );
|
401 |
+
form.find( 'input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]' ).attr( 'value', match[ 1 ] );
|
402 |
+
} );
|
403 |
+
} );
|
404 |
};
|
405 |
|
406 |
+
$.fn.wpcf7RefillQuiz = function( quiz ) {
|
407 |
+
return this.each( function() {
|
408 |
+
var form = $( this );
|
409 |
|
410 |
+
$.each( quiz, function( i, n ) {
|
411 |
+
form.find( ':input[name="' + i + '"]' ).clearFields();
|
412 |
+
form.find( ':input[name="' + i + '"]' ).siblings( 'span.wpcf7-quiz-label' ).text( n[ 0 ] );
|
413 |
+
form.find( 'input:hidden[name="_wpcf7_quiz_answer_' + i + '"]' ).attr( 'value', n[ 1 ] );
|
414 |
+
} );
|
415 |
+
} );
|
416 |
};
|
417 |
|
418 |
$.fn.wpcf7ClearResponseOutput = function() {
|
419 |
+
return this.each( function() {
|
420 |
+
$( this ).find( 'div.wpcf7-response-output' ).hide().empty().removeClass( 'wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked' ).removeAttr( 'role' );
|
421 |
+
$( this ).find( 'span.wpcf7-not-valid-tip' ).remove();
|
422 |
+
$( this ).find( '.ajax-loader' ).removeClass( 'is-active' );
|
423 |
+
} );
|
424 |
};
|
425 |
|
426 |
$.fn.wpcf7Recaptcha = function() {
|
427 |
+
return this.each( function() {
|
428 |
var events = 'wpcf7:spam wpcf7:mailsent wpcf7:mailfailed';
|
429 |
+
$( this ).closest( 'div.wpcf7' ).on( events, function( e ) {
|
430 |
+
if ( recaptchaWidgets && grecaptcha ) {
|
431 |
+
$.each( recaptchaWidgets, function( index, value ) {
|
432 |
+
grecaptcha.reset( value );
|
433 |
+
} );
|
434 |
}
|
435 |
+
} );
|
436 |
+
} );
|
437 |
};
|
438 |
|
439 |
+
$.wpcf7UpdateScreenReaderResponse = function( $form, data ) {
|
440 |
+
$( '.wpcf7 .screen-reader-response' ).html( '' ).attr( 'role', '' );
|
441 |
|
442 |
+
if ( data.message ) {
|
443 |
+
var $response = $form.siblings( '.screen-reader-response' ).first();
|
444 |
+
$response.append( data.message );
|
445 |
|
446 |
+
if ( data.invalids ) {
|
447 |
+
var $invalids = $( '<ul></ul>' );
|
448 |
|
449 |
+
$.each( data.invalids, function( i, n ) {
|
450 |
+
if ( n.idref ) {
|
451 |
+
var $li = $( '<li></li>' ).append( $( '<a></a>' ).attr( 'href', '#' + n.idref ).append( n.message ) );
|
452 |
} else {
|
453 |
+
var $li = $( '<li></li>' ).append( n.message );
|
454 |
}
|
455 |
|
456 |
+
$invalids.append( $li );
|
457 |
+
} );
|
458 |
|
459 |
+
$response.append( $invalids );
|
460 |
}
|
461 |
|
462 |
+
$response.attr( 'role', 'alert' ).focus();
|
463 |
}
|
464 |
};
|
465 |
|
466 |
$.wpcf7SupportHtml5 = function() {
|
467 |
var features = {};
|
468 |
+
var input = document.createElement( 'input' );
|
469 |
|
470 |
features.placeholder = 'placeholder' in input;
|
471 |
|
472 |
+
var inputTypes = [ 'email', 'url', 'tel', 'number', 'range', 'date' ];
|
473 |
|
474 |
+
$.each( inputTypes, function( index, value ) {
|
475 |
+
input.setAttribute( 'type', value );
|
476 |
+
features[ value ] = input.type !== 'text';
|
477 |
+
} );
|
478 |
|
479 |
return features;
|
480 |
};
|
481 |
|
482 |
+
$( function() {
|
483 |
_wpcf7.supportHtml5 = $.wpcf7SupportHtml5();
|
484 |
+
$( 'div.wpcf7 > form' ).wpcf7InitForm();
|
485 |
+
} );
|
486 |
+
|
487 |
+
} )( jQuery );
|
488 |
+
|
489 |
+
/*
|
490 |
+
* Polyfill for Internet Explorer
|
491 |
+
* See https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
|
492 |
+
*/
|
493 |
+
( function () {
|
494 |
+
if ( typeof window.CustomEvent === "function" ) return false;
|
495 |
+
|
496 |
+
function CustomEvent ( event, params ) {
|
497 |
+
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
498 |
+
var evt = document.createEvent( 'CustomEvent' );
|
499 |
+
evt.initCustomEvent( event,
|
500 |
+
params.bubbles, params.cancelable, params.detail );
|
501 |
+
return evt;
|
502 |
+
}
|
503 |
+
|
504 |
+
CustomEvent.prototype = window.Event.prototype;
|
505 |
|
506 |
+
window.CustomEvent = CustomEvent;
|
507 |
+
} )();
|
includes/l10n.php
CHANGED
@@ -15,7 +15,8 @@ function wpcf7_l10n() {
|
|
15 |
|
16 |
$api = translations_api( 'plugins', array(
|
17 |
'slug' => 'contact-form-7',
|
18 |
-
'version' => WPCF7_VERSION
|
|
|
19 |
|
20 |
if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
|
21 |
return $l10n;
|
@@ -45,7 +46,8 @@ function wpcf7_is_rtl( $locale = '' ) {
|
|
45 |
'haz' => 'Hazaragi',
|
46 |
'he_IL' => 'Hebrew',
|
47 |
'ps' => 'Pashto',
|
48 |
-
'ug_CN' => 'Uighur'
|
|
|
49 |
|
50 |
if ( empty( $locale ) && function_exists( 'is_rtl' ) ) {
|
51 |
return is_rtl();
|
15 |
|
16 |
$api = translations_api( 'plugins', array(
|
17 |
'slug' => 'contact-form-7',
|
18 |
+
'version' => WPCF7_VERSION,
|
19 |
+
) );
|
20 |
|
21 |
if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
|
22 |
return $l10n;
|
46 |
'haz' => 'Hazaragi',
|
47 |
'he_IL' => 'Hebrew',
|
48 |
'ps' => 'Pashto',
|
49 |
+
'ug_CN' => 'Uighur',
|
50 |
+
);
|
51 |
|
52 |
if ( empty( $locale ) && function_exists( 'is_rtl' ) ) {
|
53 |
return is_rtl();
|
includes/mail.php
CHANGED
@@ -24,9 +24,13 @@ class WPCF7_Mail {
|
|
24 |
$this->exclude_blank = ! empty( $template['exclude_blank'] );
|
25 |
|
26 |
$this->template = wp_parse_args( $template, array(
|
27 |
-
'subject' => '',
|
28 |
-
'
|
29 |
-
'
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
public function name() {
|
@@ -43,7 +47,8 @@ class WPCF7_Mail {
|
|
43 |
if ( $replace_tags ) {
|
44 |
$component = $this->replace_tags( $component, array(
|
45 |
'html' => $use_html,
|
46 |
-
'exclude_blank' => $exclude_blank
|
|
|
47 |
|
48 |
if ( $use_html
|
49 |
&& ! preg_match( '%<html[>\s].*</html>%is', $component ) ) {
|
@@ -79,7 +84,8 @@ class WPCF7_Mail {
|
|
79 |
'body' => $this->get( 'body', true ),
|
80 |
'recipient' => $this->get( 'recipient', true ),
|
81 |
'additional_headers' => $this->get( 'additional_headers', true ),
|
82 |
-
'attachments' => $this->attachments()
|
|
|
83 |
|
84 |
$components = apply_filters( 'wpcf7_mail_components',
|
85 |
$components, wpcf7_get_current_contact_form(), $this );
|
@@ -118,7 +124,8 @@ class WPCF7_Mail {
|
|
118 |
|
119 |
$args = wp_parse_args( $args, array(
|
120 |
'html' => false,
|
121 |
-
'exclude_blank' => false
|
|
|
122 |
|
123 |
return wpcf7_mail_replace_tags( $content, $args );
|
124 |
}
|
@@ -162,7 +169,8 @@ class WPCF7_Mail {
|
|
162 |
function wpcf7_mail_replace_tags( $content, $args = '' ) {
|
163 |
$args = wp_parse_args( $args, array(
|
164 |
'html' => false,
|
165 |
-
'exclude_blank' => false
|
|
|
166 |
|
167 |
if ( is_array( $content ) ) {
|
168 |
foreach ( $content as $key => $value ) {
|
@@ -223,7 +231,8 @@ class WPCF7_MailTaggedText {
|
|
223 |
public function __construct( $content, $args = '' ) {
|
224 |
$args = wp_parse_args( $args, array(
|
225 |
'html' => false,
|
226 |
-
'callback' => null
|
|
|
227 |
|
228 |
$this->html = (bool) $args['html'];
|
229 |
|
24 |
$this->exclude_blank = ! empty( $template['exclude_blank'] );
|
25 |
|
26 |
$this->template = wp_parse_args( $template, array(
|
27 |
+
'subject' => '',
|
28 |
+
'sender' => '',
|
29 |
+
'body' => '',
|
30 |
+
'recipient' => '',
|
31 |
+
'additional_headers' => '',
|
32 |
+
'attachments' => '',
|
33 |
+
) );
|
34 |
}
|
35 |
|
36 |
public function name() {
|
47 |
if ( $replace_tags ) {
|
48 |
$component = $this->replace_tags( $component, array(
|
49 |
'html' => $use_html,
|
50 |
+
'exclude_blank' => $exclude_blank,
|
51 |
+
) );
|
52 |
|
53 |
if ( $use_html
|
54 |
&& ! preg_match( '%<html[>\s].*</html>%is', $component ) ) {
|
84 |
'body' => $this->get( 'body', true ),
|
85 |
'recipient' => $this->get( 'recipient', true ),
|
86 |
'additional_headers' => $this->get( 'additional_headers', true ),
|
87 |
+
'attachments' => $this->attachments(),
|
88 |
+
);
|
89 |
|
90 |
$components = apply_filters( 'wpcf7_mail_components',
|
91 |
$components, wpcf7_get_current_contact_form(), $this );
|
124 |
|
125 |
$args = wp_parse_args( $args, array(
|
126 |
'html' => false,
|
127 |
+
'exclude_blank' => false,
|
128 |
+
) );
|
129 |
|
130 |
return wpcf7_mail_replace_tags( $content, $args );
|
131 |
}
|
169 |
function wpcf7_mail_replace_tags( $content, $args = '' ) {
|
170 |
$args = wp_parse_args( $args, array(
|
171 |
'html' => false,
|
172 |
+
'exclude_blank' => false,
|
173 |
+
) );
|
174 |
|
175 |
if ( is_array( $content ) ) {
|
176 |
foreach ( $content as $key => $value ) {
|
231 |
public function __construct( $content, $args = '' ) {
|
232 |
$args = wp_parse_args( $args, array(
|
233 |
'html' => false,
|
234 |
+
'callback' => null,
|
235 |
+
) );
|
236 |
|
237 |
$this->html = (bool) $args['html'];
|
238 |
|
includes/rest-api.php
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
add_action( 'rest_api_init', 'wpcf7_rest_api_init' );
|
4 |
+
|
5 |
+
function wpcf7_rest_api_init() {
|
6 |
+
$namespace = 'contact-form-7/v1';
|
7 |
+
|
8 |
+
register_rest_route( $namespace,
|
9 |
+
'/contact-forms',
|
10 |
+
array(
|
11 |
+
array(
|
12 |
+
'methods' => WP_REST_Server::READABLE,
|
13 |
+
'callback' => 'wpcf7_rest_get_contact_forms',
|
14 |
+
),
|
15 |
+
array(
|
16 |
+
'methods' => WP_REST_Server::CREATABLE,
|
17 |
+
'callback' => 'wpcf7_rest_create_contact_form',
|
18 |
+
),
|
19 |
+
)
|
20 |
+
);
|
21 |
+
|
22 |
+
register_rest_route( $namespace,
|
23 |
+
'/contact-forms/(?P<id>\d+)',
|
24 |
+
array(
|
25 |
+
array(
|
26 |
+
'methods' => WP_REST_Server::READABLE,
|
27 |
+
'callback' => 'wpcf7_rest_get_contact_form',
|
28 |
+
),
|
29 |
+
array(
|
30 |
+
'methods' => WP_REST_Server::EDITABLE,
|
31 |
+
'callback' => 'wpcf7_rest_update_contact_form',
|
32 |
+
),
|
33 |
+
array(
|
34 |
+
'methods' => WP_REST_Server::DELETABLE,
|
35 |
+
'callback' => 'wpcf7_rest_delete_contact_form',
|
36 |
+
),
|
37 |
+
)
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
function wpcf7_rest_get_contact_forms( WP_REST_Request $request ) {
|
42 |
+
if ( ! current_user_can( 'wpcf7_read_contact_forms' ) ) {
|
43 |
+
return new WP_Error( 'wpcf7_forbidden',
|
44 |
+
__( "You are not allowed to access contact forms.", 'contact-form-7' ),
|
45 |
+
array( 'status' => 403 ) );
|
46 |
+
}
|
47 |
+
|
48 |
+
$args = array();
|
49 |
+
|
50 |
+
$per_page = $request->get_param( 'per_page' );
|
51 |
+
|
52 |
+
if ( null !== $per_page ) {
|
53 |
+
$args['posts_per_page'] = (int) $per_page;
|
54 |
+
}
|
55 |
+
|
56 |
+
$offset = $request->get_param( 'offset' );
|
57 |
+
|
58 |
+
if ( null !== $offset ) {
|
59 |
+
$args['offset'] = (int) $offset;
|
60 |
+
}
|
61 |
+
|
62 |
+
$order = $request->get_param( 'order' );
|
63 |
+
|
64 |
+
if ( null !== $order ) {
|
65 |
+
$args['order'] = (string) $order;
|
66 |
+
}
|
67 |
+
|
68 |
+
$orderby = $request->get_param( 'orderby' );
|
69 |
+
|
70 |
+
if ( null !== $orderby ) {
|
71 |
+
$args['orderby'] = (string) $orderby;
|
72 |
+
}
|
73 |
+
|
74 |
+
$search = $request->get_param( 'search' );
|
75 |
+
|
76 |
+
if ( null !== $search ) {
|
77 |
+
$args['s'] = (string) $search;
|
78 |
+
}
|
79 |
+
|
80 |
+
$items = WPCF7_ContactForm::find( $args );
|
81 |
+
|
82 |
+
$response = array();
|
83 |
+
|
84 |
+
foreach ( $items as $item ) {
|
85 |
+
$response[] = array(
|
86 |
+
'id' => $item->id(),
|
87 |
+
'slug' => $item->name(),
|
88 |
+
'title' => $item->title(),
|
89 |
+
'locale' => $item->locale(),
|
90 |
+
);
|
91 |
+
}
|
92 |
+
|
93 |
+
return rest_ensure_response( $response );
|
94 |
+
}
|
95 |
+
|
96 |
+
function wpcf7_rest_create_contact_form( WP_REST_Request $request ) {
|
97 |
+
$id = (int) $request->get_param( 'id' );
|
98 |
+
|
99 |
+
if ( $id ) {
|
100 |
+
return new WP_Error( 'wpcf7_post_exists',
|
101 |
+
__( "Cannot create existing contact form.", 'contact-form-7' ),
|
102 |
+
array( 'status' => 400 ) );
|
103 |
+
}
|
104 |
+
|
105 |
+
if ( ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
106 |
+
return new WP_Error( 'wpcf7_forbidden',
|
107 |
+
__( "You are not allowed to create a contact form.", 'contact-form-7' ),
|
108 |
+
array( 'status' => 403 ) );
|
109 |
+
}
|
110 |
+
|
111 |
+
$args = $request->get_params();
|
112 |
+
$args['id'] = -1; // Create
|
113 |
+
$context = $request->get_param( 'context' );
|
114 |
+
$item = wpcf7_save_contact_form( $args, $context );
|
115 |
+
|
116 |
+
if ( ! $item ) {
|
117 |
+
return new WP_Error( 'wpcf7_cannot_save',
|
118 |
+
__( "There was an error saving the contact form.", 'contact-form-7' ),
|
119 |
+
array( 'status' => 500 ) );
|
120 |
+
}
|
121 |
+
|
122 |
+
$response = array(
|
123 |
+
'id' => $item->id(),
|
124 |
+
'slug' => $item->name(),
|
125 |
+
'title' => $item->title(),
|
126 |
+
'locale' => $item->locale(),
|
127 |
+
'properties' => $item->get_properties(),
|
128 |
+
'config_errors' => array(),
|
129 |
+
);
|
130 |
+
|
131 |
+
if ( wpcf7_validate_configuration() ) {
|
132 |
+
$config_validator = new WPCF7_ConfigValidator( $item );
|
133 |
+
$config_validator->validate();
|
134 |
+
|
135 |
+
$response['config_errors'] = $config_validator->collect_error_messages();
|
136 |
+
|
137 |
+
if ( 'save' == $context ) {
|
138 |
+
$config_validator->save();
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
return rest_ensure_response( $response );
|
143 |
+
}
|
144 |
+
|
145 |
+
function wpcf7_rest_get_contact_form( WP_REST_Request $request ) {
|
146 |
+
$id = (int) $request->get_param( 'id' );
|
147 |
+
$item = wpcf7_contact_form( $id );
|
148 |
+
|
149 |
+
if ( ! $item ) {
|
150 |
+
return new WP_Error( 'wpcf7_not_found',
|
151 |
+
__( "The requested contact form was not found.", 'contact-form-7' ),
|
152 |
+
array( 'status' => 404 ) );
|
153 |
+
}
|
154 |
+
|
155 |
+
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
|
156 |
+
return new WP_Error( 'wpcf7_forbidden',
|
157 |
+
__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
|
158 |
+
array( 'status' => 403 ) );
|
159 |
+
}
|
160 |
+
|
161 |
+
$response = array(
|
162 |
+
'id' => $item->id(),
|
163 |
+
'slug' => $item->name(),
|
164 |
+
'title' => $item->title(),
|
165 |
+
'locale' => $item->locale(),
|
166 |
+
'properties' => $item->get_properties(),
|
167 |
+
);
|
168 |
+
|
169 |
+
return rest_ensure_response( $response );
|
170 |
+
}
|
171 |
+
|
172 |
+
function wpcf7_rest_update_contact_form( WP_REST_Request $request ) {
|
173 |
+
$id = (int) $request->get_param( 'id' );
|
174 |
+
$item = wpcf7_contact_form( $id );
|
175 |
+
|
176 |
+
if ( ! $item ) {
|
177 |
+
return new WP_Error( 'wpcf7_not_found',
|
178 |
+
__( "The requested contact form was not found.", 'contact-form-7' ),
|
179 |
+
array( 'status' => 404 ) );
|
180 |
+
}
|
181 |
+
|
182 |
+
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
|
183 |
+
return new WP_Error( 'wpcf7_forbidden',
|
184 |
+
__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
|
185 |
+
array( 'status' => 403 ) );
|
186 |
+
}
|
187 |
+
|
188 |
+
$args = $request->get_params();
|
189 |
+
$context = $request->get_param( 'context' );
|
190 |
+
$item = wpcf7_save_contact_form( $args, $context );
|
191 |
+
|
192 |
+
if ( ! $item ) {
|
193 |
+
return new WP_Error( 'wpcf7_cannot_save',
|
194 |
+
__( "There was an error saving the contact form.", 'contact-form-7' ),
|
195 |
+
array( 'status' => 500 ) );
|
196 |
+
}
|
197 |
+
|
198 |
+
$response = array(
|
199 |
+
'id' => $item->id(),
|
200 |
+
'slug' => $item->name(),
|
201 |
+
'title' => $item->title(),
|
202 |
+
'locale' => $item->locale(),
|
203 |
+
'properties' => $item->get_properties(),
|
204 |
+
'config_errors' => array(),
|
205 |
+
);
|
206 |
+
|
207 |
+
if ( wpcf7_validate_configuration() ) {
|
208 |
+
$config_validator = new WPCF7_ConfigValidator( $item );
|
209 |
+
$config_validator->validate();
|
210 |
+
|
211 |
+
$response['config_errors'] = $config_validator->collect_error_messages();
|
212 |
+
|
213 |
+
if ( 'save' == $context ) {
|
214 |
+
$config_validator->save();
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return rest_ensure_response( $response );
|
219 |
+
}
|
220 |
+
|
221 |
+
function wpcf7_rest_delete_contact_form( WP_REST_Request $request ) {
|
222 |
+
$id = (int) $request->get_param( 'id' );
|
223 |
+
$item = wpcf7_contact_form( $id );
|
224 |
+
|
225 |
+
if ( ! $item ) {
|
226 |
+
return new WP_Error( 'wpcf7_not_found',
|
227 |
+
__( "The requested contact form was not found.", 'contact-form-7' ),
|
228 |
+
array( 'status' => 404 ) );
|
229 |
+
}
|
230 |
+
|
231 |
+
if ( ! current_user_can( 'wpcf7_delete_contact_form', $id ) ) {
|
232 |
+
return new WP_Error( 'wpcf7_forbidden',
|
233 |
+
__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
|
234 |
+
array( 'status' => 403 ) );
|
235 |
+
}
|
236 |
+
|
237 |
+
$result = $item->delete();
|
238 |
+
|
239 |
+
if ( ! $result ) {
|
240 |
+
return new WP_Error( 'wpcf7_cannot_delete',
|
241 |
+
__( "There was an error deleting the contact form.", 'contact-form-7' ),
|
242 |
+
array( 'status' => 500 ) );
|
243 |
+
}
|
244 |
+
|
245 |
+
$response = array( 'deleted' => true );
|
246 |
+
|
247 |
+
return rest_ensure_response( $response );
|
248 |
+
}
|
includes/submission.php
CHANGED
@@ -137,8 +137,9 @@ class WPCF7_Submission {
|
|
137 |
'url' => preg_replace( '%(?<!:|/)/.*$%', '',
|
138 |
untrailingslashit( home_url() ) ) . wpcf7_get_request_uri(),
|
139 |
'timestamp' => current_time( 'timestamp' ),
|
140 |
-
'unit_tag' =>
|
141 |
-
? $_POST['_wpcf7_unit_tag'] : ''
|
|
|
142 |
|
143 |
$contact_form = $this->contact_form;
|
144 |
|
@@ -192,8 +193,8 @@ class WPCF7_Submission {
|
|
192 |
$tags = $this->contact_form->scan_form_tags();
|
193 |
|
194 |
foreach ( $tags as $tag ) {
|
195 |
-
$
|
196 |
-
|
197 |
}
|
198 |
|
199 |
$result = apply_filters( 'wpcf7_validate', $result, $tags );
|
137 |
'url' => preg_replace( '%(?<!:|/)/.*$%', '',
|
138 |
untrailingslashit( home_url() ) ) . wpcf7_get_request_uri(),
|
139 |
'timestamp' => current_time( 'timestamp' ),
|
140 |
+
'unit_tag' =>
|
141 |
+
isset( $_POST['_wpcf7_unit_tag'] ) ? $_POST['_wpcf7_unit_tag'] : '',
|
142 |
+
);
|
143 |
|
144 |
$contact_form = $this->contact_form;
|
145 |
|
193 |
$tags = $this->contact_form->scan_form_tags();
|
194 |
|
195 |
foreach ( $tags as $tag ) {
|
196 |
+
$type = $tag['type'];
|
197 |
+
$result = apply_filters( "wpcf7_validate_{$type}", $result, $tag );
|
198 |
}
|
199 |
|
200 |
$result = apply_filters( 'wpcf7_validate', $result, $tags );
|
includes/upgrade.php
CHANGED
@@ -32,7 +32,8 @@ function wpcf7_convert_to_cpt( $new_ver, $old_ver ) {
|
|
32 |
$postarr = array(
|
33 |
'post_type' => 'wpcf7_contact_form',
|
34 |
'post_status' => 'publish',
|
35 |
-
'post_title' => maybe_unserialize( $row->title )
|
|
|
36 |
|
37 |
$post_id = wp_insert_post( $postarr );
|
38 |
|
@@ -62,7 +63,8 @@ function wpcf7_prepend_underscore( $new_ver, $old_ver ) {
|
|
62 |
|
63 |
$posts = WPCF7_ContactForm::find( array(
|
64 |
'post_status' => 'any',
|
65 |
-
'posts_per_page' => -1
|
|
|
66 |
|
67 |
foreach ( $posts as $post ) {
|
68 |
$props = $post->get_properties();
|
32 |
$postarr = array(
|
33 |
'post_type' => 'wpcf7_contact_form',
|
34 |
'post_status' => 'publish',
|
35 |
+
'post_title' => maybe_unserialize( $row->title ),
|
36 |
+
);
|
37 |
|
38 |
$post_id = wp_insert_post( $postarr );
|
39 |
|
63 |
|
64 |
$posts = WPCF7_ContactForm::find( array(
|
65 |
'post_status' => 'any',
|
66 |
+
'posts_per_page' => -1,
|
67 |
+
) );
|
68 |
|
69 |
foreach ( $posts as $post ) {
|
70 |
$props = $post->get_properties();
|
includes/validation.php
CHANGED
@@ -8,7 +8,8 @@ class WPCF7_Validation implements ArrayAccess {
|
|
8 |
$this->container = array(
|
9 |
'valid' => true,
|
10 |
'reason' => array(),
|
11 |
-
'idref' => array()
|
|
|
12 |
}
|
13 |
|
14 |
public function invalidate( $context, $message ) {
|
@@ -36,7 +37,8 @@ class WPCF7_Validation implements ArrayAccess {
|
|
36 |
|
37 |
$this->invalid_fields[$name] = array(
|
38 |
'reason' => (string) $message,
|
39 |
-
'idref' => $id
|
|
|
40 |
}
|
41 |
}
|
42 |
|
8 |
$this->container = array(
|
9 |
'valid' => true,
|
10 |
'reason' => array(),
|
11 |
+
'idref' => array(),
|
12 |
+
);
|
13 |
}
|
14 |
|
15 |
public function invalidate( $context, $message ) {
|
37 |
|
38 |
$this->invalid_fields[$name] = array(
|
39 |
'reason' => (string) $message,
|
40 |
+
'idref' => $id,
|
41 |
+
);
|
42 |
}
|
43 |
}
|
44 |
|
modules/acceptance.php
CHANGED
@@ -9,7 +9,7 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_acceptance' );
|
|
9 |
|
10 |
function wpcf7_add_form_tag_acceptance() {
|
11 |
wpcf7_add_form_tag( 'acceptance',
|
12 |
-
'wpcf7_acceptance_form_tag_handler', true );
|
13 |
}
|
14 |
|
15 |
function wpcf7_acceptance_form_tag_handler( $tag ) {
|
@@ -142,7 +142,7 @@ function wpcf7_tag_generator_acceptance( $contact_form, $args = '' ) {
|
|
142 |
|
143 |
$description = __( "Generate a form-tag for an acceptance checkbox. For more details, see %s.", 'contact-form-7' );
|
144 |
|
145 |
-
$desc_link = wpcf7_link( __( '
|
146 |
|
147 |
?>
|
148 |
<div class="control-box">
|
9 |
|
10 |
function wpcf7_add_form_tag_acceptance() {
|
11 |
wpcf7_add_form_tag( 'acceptance',
|
12 |
+
'wpcf7_acceptance_form_tag_handler', array( 'name-attr' => true ) );
|
13 |
}
|
14 |
|
15 |
function wpcf7_acceptance_form_tag_handler( $tag ) {
|
142 |
|
143 |
$description = __( "Generate a form-tag for an acceptance checkbox. For more details, see %s.", 'contact-form-7' );
|
144 |
|
145 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/acceptance-checkbox/', 'contact-form-7' ), __( 'Acceptance Checkbox', 'contact-form-7' ) );
|
146 |
|
147 |
?>
|
148 |
<div class="control-box">
|
modules/checkbox.php
CHANGED
@@ -9,7 +9,10 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_checkbox' );
|
|
9 |
|
10 |
function wpcf7_add_form_tag_checkbox() {
|
11 |
wpcf7_add_form_tag( array( 'checkbox', 'checkbox*', 'radio' ),
|
12 |
-
'wpcf7_checkbox_form_tag_handler',
|
|
|
|
|
|
|
13 |
}
|
14 |
|
15 |
function wpcf7_checkbox_form_tag_handler( $tag ) {
|
@@ -289,7 +292,7 @@ function wpcf7_tag_generator_checkbox( $contact_form, $args = '' ) {
|
|
289 |
$description = __( "Generate a form-tag for a group of radio buttons. For more details, see %s.", 'contact-form-7' );
|
290 |
}
|
291 |
|
292 |
-
$desc_link = wpcf7_link( __( '
|
293 |
|
294 |
?>
|
295 |
<div class="control-box">
|
9 |
|
10 |
function wpcf7_add_form_tag_checkbox() {
|
11 |
wpcf7_add_form_tag( array( 'checkbox', 'checkbox*', 'radio' ),
|
12 |
+
'wpcf7_checkbox_form_tag_handler', array(
|
13 |
+
'name-attr' => true,
|
14 |
+
'selectable-values' => true,
|
15 |
+
'multiple-controls-container' => true ) );
|
16 |
}
|
17 |
|
18 |
function wpcf7_checkbox_form_tag_handler( $tag ) {
|
292 |
$description = __( "Generate a form-tag for a group of radio buttons. For more details, see %s.", 'contact-form-7' );
|
293 |
}
|
294 |
|
295 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/checkboxes-radio-buttons-and-menus/', 'contact-form-7' ), __( 'Checkboxes, Radio Buttons and Menus', 'contact-form-7' ) );
|
296 |
|
297 |
?>
|
298 |
<div class="control-box">
|
modules/count.php
CHANGED
@@ -8,7 +8,8 @@
|
|
8 |
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_count' );
|
9 |
|
10 |
function wpcf7_add_form_tag_count() {
|
11 |
-
wpcf7_add_form_tag( 'count',
|
|
|
12 |
}
|
13 |
|
14 |
function wpcf7_count_form_tag_handler( $tag ) {
|
8 |
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', array( 'name-attr' => true ) );
|
13 |
}
|
14 |
|
15 |
function wpcf7_count_form_tag_handler( $tag ) {
|
modules/date.php
CHANGED
@@ -10,7 +10,7 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_date' );
|
|
10 |
|
11 |
function wpcf7_add_form_tag_date() {
|
12 |
wpcf7_add_form_tag( array( 'date', 'date*' ),
|
13 |
-
'wpcf7_date_form_tag_handler', true );
|
14 |
}
|
15 |
|
16 |
function wpcf7_date_form_tag_handler( $tag ) {
|
@@ -150,7 +150,7 @@ function wpcf7_tag_generator_date( $contact_form, $args = '' ) {
|
|
150 |
|
151 |
$description = __( "Generate a form-tag for a date input field. For more details, see %s.", 'contact-form-7' );
|
152 |
|
153 |
-
$desc_link = wpcf7_link( __( '
|
154 |
|
155 |
?>
|
156 |
<div class="control-box">
|
10 |
|
11 |
function wpcf7_add_form_tag_date() {
|
12 |
wpcf7_add_form_tag( array( 'date', 'date*' ),
|
13 |
+
'wpcf7_date_form_tag_handler', array( 'name-attr' => true ) );
|
14 |
}
|
15 |
|
16 |
function wpcf7_date_form_tag_handler( $tag ) {
|
150 |
|
151 |
$description = __( "Generate a form-tag for a date input field. For more details, see %s.", 'contact-form-7' );
|
152 |
|
153 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/date-field/', 'contact-form-7' ), __( 'Date Field', 'contact-form-7' ) );
|
154 |
|
155 |
?>
|
156 |
<div class="control-box">
|
modules/file.php
CHANGED
@@ -9,7 +9,7 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_file' );
|
|
9 |
|
10 |
function wpcf7_add_form_tag_file() {
|
11 |
wpcf7_add_form_tag( array( 'file', 'file*' ),
|
12 |
-
'wpcf7_file_form_tag_handler', true );
|
13 |
}
|
14 |
|
15 |
function wpcf7_file_form_tag_handler( $tag ) {
|
@@ -233,7 +233,7 @@ function wpcf7_tag_generator_file( $contact_form, $args = '' ) {
|
|
233 |
|
234 |
$description = __( "Generate a form-tag for a file uploading field. For more details, see %s.", 'contact-form-7' );
|
235 |
|
236 |
-
$desc_link = wpcf7_link( __( '
|
237 |
|
238 |
?>
|
239 |
<div class="control-box">
|
9 |
|
10 |
function wpcf7_add_form_tag_file() {
|
11 |
wpcf7_add_form_tag( array( 'file', 'file*' ),
|
12 |
+
'wpcf7_file_form_tag_handler', array( 'name-attr' => true ) );
|
13 |
}
|
14 |
|
15 |
function wpcf7_file_form_tag_handler( $tag ) {
|
233 |
|
234 |
$description = __( "Generate a form-tag for a file uploading field. For more details, see %s.", 'contact-form-7' );
|
235 |
|
236 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/file-uploading-and-attachment/', 'contact-form-7' ), __( 'File Uploading and Attachment', 'contact-form-7' ) );
|
237 |
|
238 |
?>
|
239 |
<div class="control-box">
|
modules/flamingo.php
CHANGED
@@ -66,7 +66,7 @@ function wpcf7_flamingo_submit( $contactform, $result ) {
|
|
66 |
$akismet = isset( $submission->akismet ) ? (array) $submission->akismet : null;
|
67 |
|
68 |
if ( 'mail_sent' == $result['status'] ) {
|
69 |
-
Flamingo_Contact::add( array(
|
70 |
'email' => $email,
|
71 |
'name' => $name ) );
|
72 |
}
|
@@ -98,7 +98,15 @@ function wpcf7_flamingo_submit( $contactform, $result ) {
|
|
98 |
'akismet' => $akismet,
|
99 |
'spam' => ( 'spam' == $result['status'] ) );
|
100 |
|
101 |
-
Flamingo_Inbound_Message::add( $args );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
103 |
|
104 |
function wpcf7_flamingo_get_value( $field, $contactform ) {
|
66 |
$akismet = isset( $submission->akismet ) ? (array) $submission->akismet : null;
|
67 |
|
68 |
if ( 'mail_sent' == $result['status'] ) {
|
69 |
+
$flamingo_contact = Flamingo_Contact::add( array(
|
70 |
'email' => $email,
|
71 |
'name' => $name ) );
|
72 |
}
|
98 |
'akismet' => $akismet,
|
99 |
'spam' => ( 'spam' == $result['status'] ) );
|
100 |
|
101 |
+
$flamingo_inbound = Flamingo_Inbound_Message::add( $args );
|
102 |
+
|
103 |
+
$result += array(
|
104 |
+
'flamingo_contact_id' =>
|
105 |
+
empty( $flamingo_contact ) ? 0 : absint( $flamingo_contact->id ),
|
106 |
+
'flamingo_inbound_id' =>
|
107 |
+
empty( $flamingo_inbound ) ? 0 : absint( $flamingo_inbound->id ) );
|
108 |
+
|
109 |
+
do_action( 'wpcf7_after_flamingo', $result );
|
110 |
}
|
111 |
|
112 |
function wpcf7_flamingo_get_value( $field, $contactform ) {
|
modules/hidden.php
CHANGED
@@ -3,7 +3,8 @@
|
|
3 |
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_hidden' );
|
4 |
|
5 |
function wpcf7_add_form_tag_hidden() {
|
6 |
-
wpcf7_add_form_tag( 'hidden',
|
|
|
7 |
}
|
8 |
|
9 |
function wpcf7_hidden_form_tag_handler( $tag ) {
|
3 |
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_hidden' );
|
4 |
|
5 |
function wpcf7_add_form_tag_hidden() {
|
6 |
+
wpcf7_add_form_tag( 'hidden',
|
7 |
+
'wpcf7_hidden_form_tag_handler', array( 'name-attr' => true ) );
|
8 |
}
|
9 |
|
10 |
function wpcf7_hidden_form_tag_handler( $tag ) {
|
modules/listo.php
CHANGED
@@ -14,7 +14,7 @@ function wpcf7_listo( $data, $options, $args ) {
|
|
14 |
$args = wp_parse_args( $args, array() );
|
15 |
|
16 |
$contact_form = wpcf7_get_current_contact_form();
|
17 |
-
$args['locale'] = $contact_form->locale;
|
18 |
|
19 |
foreach ( (array) $options as $option ) {
|
20 |
$option = explode( '.', $option );
|
14 |
$args = wp_parse_args( $args, array() );
|
15 |
|
16 |
$contact_form = wpcf7_get_current_contact_form();
|
17 |
+
$args['locale'] = $contact_form->locale();
|
18 |
|
19 |
foreach ( (array) $options as $option ) {
|
20 |
$option = explode( '.', $option );
|
modules/number.php
CHANGED
@@ -11,7 +11,7 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_number' );
|
|
11 |
|
12 |
function wpcf7_add_form_tag_number() {
|
13 |
wpcf7_add_form_tag( array( 'number', 'number*', 'range', 'range*' ),
|
14 |
-
'wpcf7_number_form_tag_handler', true );
|
15 |
}
|
16 |
|
17 |
function wpcf7_number_form_tag_handler( $tag ) {
|
@@ -153,7 +153,7 @@ function wpcf7_tag_generator_number( $contact_form, $args = '' ) {
|
|
153 |
|
154 |
$description = __( "Generate a form-tag for a field for numeric value input. For more details, see %s.", 'contact-form-7' );
|
155 |
|
156 |
-
$desc_link = wpcf7_link( __( '
|
157 |
|
158 |
?>
|
159 |
<div class="control-box">
|
11 |
|
12 |
function wpcf7_add_form_tag_number() {
|
13 |
wpcf7_add_form_tag( array( 'number', 'number*', 'range', 'range*' ),
|
14 |
+
'wpcf7_number_form_tag_handler', array( 'name-attr' => true ) );
|
15 |
}
|
16 |
|
17 |
function wpcf7_number_form_tag_handler( $tag ) {
|
153 |
|
154 |
$description = __( "Generate a form-tag for a field for numeric value input. For more details, see %s.", 'contact-form-7' );
|
155 |
|
156 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/number-fields/', 'contact-form-7' ), __( 'Number Fields', 'contact-form-7' ) );
|
157 |
|
158 |
?>
|
159 |
<div class="control-box">
|
modules/quiz.php
CHANGED
@@ -8,7 +8,8 @@
|
|
8 |
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_quiz' );
|
9 |
|
10 |
function wpcf7_add_form_tag_quiz() {
|
11 |
-
wpcf7_add_form_tag( 'quiz',
|
|
|
12 |
}
|
13 |
|
14 |
function wpcf7_quiz_form_tag_handler( $tag ) {
|
@@ -171,7 +172,7 @@ function wpcf7_tag_generator_quiz( $contact_form, $args = '' ) {
|
|
171 |
|
172 |
$description = __( "Generate a form-tag for a question-answer pair. For more details, see %s.", 'contact-form-7' );
|
173 |
|
174 |
-
$desc_link = wpcf7_link( __( '
|
175 |
|
176 |
?>
|
177 |
<div class="control-box">
|
8 |
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_quiz' );
|
9 |
|
10 |
function wpcf7_add_form_tag_quiz() {
|
11 |
+
wpcf7_add_form_tag( 'quiz',
|
12 |
+
'wpcf7_quiz_form_tag_handler', array( 'name-attr' => true ) );
|
13 |
}
|
14 |
|
15 |
function wpcf7_quiz_form_tag_handler( $tag ) {
|
172 |
|
173 |
$description = __( "Generate a form-tag for a question-answer pair. For more details, see %s.", 'contact-form-7' );
|
174 |
|
175 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/quiz/', 'contact-form-7' ), __( 'Quiz', 'contact-form-7' ) );
|
176 |
|
177 |
?>
|
178 |
<div class="control-box">
|
modules/really-simple-captcha.php
CHANGED
@@ -9,7 +9,7 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_captcha' );
|
|
9 |
|
10 |
function wpcf7_add_form_tag_captcha() {
|
11 |
wpcf7_add_form_tag( array( 'captchac', 'captchar' ),
|
12 |
-
'wpcf7_captcha_form_tag_handler', true );
|
13 |
}
|
14 |
|
15 |
function wpcf7_captcha_form_tag_handler( $tag ) {
|
@@ -228,7 +228,7 @@ function wpcf7_tag_generator_captcha( $contact_form, $args = '' ) {
|
|
228 |
|
229 |
$description = __( "Generate form-tags for a CAPTCHA image and corresponding response input field. For more details, see %s.", 'contact-form-7' );
|
230 |
|
231 |
-
$desc_link = wpcf7_link( __( '
|
232 |
|
233 |
?>
|
234 |
<div class="control-box">
|
9 |
|
10 |
function wpcf7_add_form_tag_captcha() {
|
11 |
wpcf7_add_form_tag( array( 'captchac', 'captchar' ),
|
12 |
+
'wpcf7_captcha_form_tag_handler', array( 'name-attr' => true ) );
|
13 |
}
|
14 |
|
15 |
function wpcf7_captcha_form_tag_handler( $tag ) {
|
228 |
|
229 |
$description = __( "Generate form-tags for a CAPTCHA image and corresponding response input field. For more details, see %s.", 'contact-form-7' );
|
230 |
|
231 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/captcha/', 'contact-form-7' ), __( 'CAPTCHA', 'contact-form-7' ) );
|
232 |
|
233 |
?>
|
234 |
<div class="control-box">
|
modules/recaptcha.php
CHANGED
@@ -181,7 +181,7 @@ class WPCF7_RECAPTCHA extends WPCF7_Service {
|
|
181 |
|
182 |
<p><a href="<?php echo esc_url( $this->menu_page_url( 'action=setup' ) ); ?>" class="button"><?php echo esc_html( __( "Configure Keys", 'contact-form-7' ) ); ?></a></p>
|
183 |
|
184 |
-
<p><?php echo sprintf( esc_html( __( "For more details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( '
|
185 |
<?php
|
186 |
}
|
187 |
}
|
@@ -303,6 +303,10 @@ function wpcf7_recaptcha_add_form_tag_recaptcha() {
|
|
303 |
}
|
304 |
|
305 |
function wpcf7_recaptcha_form_tag_handler( $tag ) {
|
|
|
|
|
|
|
|
|
306 |
wp_enqueue_script( 'google-recaptcha' );
|
307 |
|
308 |
$tag = new WPCF7_FormTag( $tag );
|
@@ -411,7 +415,7 @@ function wpcf7_tag_generator_recaptcha( $contact_form, $args = '' ) {
|
|
411 |
?>
|
412 |
<div class="control-box">
|
413 |
<fieldset>
|
414 |
-
<legend><?php echo sprintf( esc_html( __( "To use reCAPTCHA, first you need to install an API key pair. For more details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( '
|
415 |
</fieldset>
|
416 |
</div>
|
417 |
<?php
|
@@ -421,7 +425,7 @@ function wpcf7_tag_generator_recaptcha( $contact_form, $args = '' ) {
|
|
421 |
|
422 |
$description = __( "Generate a form-tag for a reCAPTCHA widget. For more details, see %s.", 'contact-form-7' );
|
423 |
|
424 |
-
$desc_link = wpcf7_link( __( '
|
425 |
|
426 |
?>
|
427 |
<div class="control-box">
|
181 |
|
182 |
<p><a href="<?php echo esc_url( $this->menu_page_url( 'action=setup' ) ); ?>" class="button"><?php echo esc_html( __( "Configure Keys", 'contact-form-7' ) ); ?></a></p>
|
183 |
|
184 |
+
<p><?php echo sprintf( esc_html( __( "For more details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ) ); ?></p>
|
185 |
<?php
|
186 |
}
|
187 |
}
|
303 |
}
|
304 |
|
305 |
function wpcf7_recaptcha_form_tag_handler( $tag ) {
|
306 |
+
if ( ! wp_script_is( 'google-recaptcha', 'registered' ) ) {
|
307 |
+
wpcf7_recaptcha_enqueue_scripts();
|
308 |
+
}
|
309 |
+
|
310 |
wp_enqueue_script( 'google-recaptcha' );
|
311 |
|
312 |
$tag = new WPCF7_FormTag( $tag );
|
415 |
?>
|
416 |
<div class="control-box">
|
417 |
<fieldset>
|
418 |
+
<legend><?php echo sprintf( esc_html( __( "To use reCAPTCHA, first you need to install an API key pair. For more details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ) ); ?></legend>
|
419 |
</fieldset>
|
420 |
</div>
|
421 |
<?php
|
425 |
|
426 |
$description = __( "Generate a form-tag for a reCAPTCHA widget. For more details, see %s.", 'contact-form-7' );
|
427 |
|
428 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) );
|
429 |
|
430 |
?>
|
431 |
<div class="control-box">
|
modules/select.php
CHANGED
@@ -9,7 +9,8 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_select' );
|
|
9 |
|
10 |
function wpcf7_add_form_tag_select() {
|
11 |
wpcf7_add_form_tag( array( 'select', 'select*' ),
|
12 |
-
'wpcf7_select_form_tag_handler',
|
|
|
13 |
}
|
14 |
|
15 |
function wpcf7_select_form_tag_handler( $tag ) {
|
@@ -43,6 +44,18 @@ function wpcf7_select_form_tag_handler( $tag ) {
|
|
43 |
$include_blank = $tag->has_option( 'include_blank' );
|
44 |
$first_as_label = $tag->has_option( 'first_as_label' );
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
$values = $tag->values;
|
47 |
$labels = $tag->labels;
|
48 |
|
@@ -111,8 +124,9 @@ function wpcf7_select_form_tag_handler( $tag ) {
|
|
111 |
$item_atts, esc_html( $label ) );
|
112 |
}
|
113 |
|
114 |
-
if ( $multiple )
|
115 |
$atts['multiple'] = 'multiple';
|
|
|
116 |
|
117 |
$atts['name'] = $tag->name . ( $multiple ? '[]' : '' );
|
118 |
|
@@ -138,8 +152,9 @@ function wpcf7_select_validation_filter( $result, $tag ) {
|
|
138 |
|
139 |
if ( isset( $_POST[$name] ) && is_array( $_POST[$name] ) ) {
|
140 |
foreach ( $_POST[$name] as $key => $value ) {
|
141 |
-
if ( '' === $value )
|
142 |
unset( $_POST[$name][$key] );
|
|
|
143 |
}
|
144 |
}
|
145 |
|
@@ -168,7 +183,7 @@ function wpcf7_tag_generator_menu( $contact_form, $args = '' ) {
|
|
168 |
|
169 |
$description = __( "Generate a form-tag for a drop-down menu. For more details, see %s.", 'contact-form-7' );
|
170 |
|
171 |
-
$desc_link = wpcf7_link( __( '
|
172 |
|
173 |
?>
|
174 |
<div class="control-box">
|
9 |
|
10 |
function wpcf7_add_form_tag_select() {
|
11 |
wpcf7_add_form_tag( array( 'select', 'select*' ),
|
12 |
+
'wpcf7_select_form_tag_handler',
|
13 |
+
array( 'name-attr' => true, 'selectable-values' => true ) );
|
14 |
}
|
15 |
|
16 |
function wpcf7_select_form_tag_handler( $tag ) {
|
44 |
$include_blank = $tag->has_option( 'include_blank' );
|
45 |
$first_as_label = $tag->has_option( 'first_as_label' );
|
46 |
|
47 |
+
if ( $tag->has_option( 'size' ) ) {
|
48 |
+
$size = $tag->get_option( 'size', 'int', true );
|
49 |
+
|
50 |
+
if ( $size ) {
|
51 |
+
$atts['size'] = $size;
|
52 |
+
} elseif ( $multiple ) {
|
53 |
+
$atts['size'] = 4;
|
54 |
+
} else {
|
55 |
+
$atts['size'] = 1;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
$values = $tag->values;
|
60 |
$labels = $tag->labels;
|
61 |
|
124 |
$item_atts, esc_html( $label ) );
|
125 |
}
|
126 |
|
127 |
+
if ( $multiple ) {
|
128 |
$atts['multiple'] = 'multiple';
|
129 |
+
}
|
130 |
|
131 |
$atts['name'] = $tag->name . ( $multiple ? '[]' : '' );
|
132 |
|
152 |
|
153 |
if ( isset( $_POST[$name] ) && is_array( $_POST[$name] ) ) {
|
154 |
foreach ( $_POST[$name] as $key => $value ) {
|
155 |
+
if ( '' === $value ) {
|
156 |
unset( $_POST[$name][$key] );
|
157 |
+
}
|
158 |
}
|
159 |
}
|
160 |
|
183 |
|
184 |
$description = __( "Generate a form-tag for a drop-down menu. For more details, see %s.", 'contact-form-7' );
|
185 |
|
186 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/checkboxes-radio-buttons-and-menus/', 'contact-form-7' ), __( 'Checkboxes, Radio Buttons and Menus', 'contact-form-7' ) );
|
187 |
|
188 |
?>
|
189 |
<div class="control-box">
|
modules/submit.php
CHANGED
@@ -54,7 +54,7 @@ function wpcf7_tag_generator_submit( $contact_form, $args = '' ) {
|
|
54 |
|
55 |
$description = __( "Generate a form-tag for a submit button. For more details, see %s.", 'contact-form-7' );
|
56 |
|
57 |
-
$desc_link = wpcf7_link( __( '
|
58 |
|
59 |
?>
|
60 |
<div class="control-box">
|
54 |
|
55 |
$description = __( "Generate a form-tag for a submit button. For more details, see %s.", 'contact-form-7' );
|
56 |
|
57 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/submit-button/', 'contact-form-7' ), __( 'Submit Button', 'contact-form-7' ) );
|
58 |
|
59 |
?>
|
60 |
<div class="control-box">
|
modules/text.php
CHANGED
@@ -14,7 +14,7 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_text' );
|
|
14 |
function wpcf7_add_form_tag_text() {
|
15 |
wpcf7_add_form_tag(
|
16 |
array( 'text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*' ),
|
17 |
-
'wpcf7_text_form_tag_handler', true );
|
18 |
}
|
19 |
|
20 |
function wpcf7_text_form_tag_handler( $tag ) {
|
@@ -225,7 +225,7 @@ function wpcf7_tag_generator_text( $contact_form, $args = '' ) {
|
|
225 |
$description = __( "Generate a form-tag for a single-line telephone number input field. For more details, see %s.", 'contact-form-7' );
|
226 |
}
|
227 |
|
228 |
-
$desc_link = wpcf7_link( __( '
|
229 |
|
230 |
?>
|
231 |
<div class="control-box">
|
14 |
function wpcf7_add_form_tag_text() {
|
15 |
wpcf7_add_form_tag(
|
16 |
array( 'text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*' ),
|
17 |
+
'wpcf7_text_form_tag_handler', array( 'name-attr' => true ) );
|
18 |
}
|
19 |
|
20 |
function wpcf7_text_form_tag_handler( $tag ) {
|
225 |
$description = __( "Generate a form-tag for a single-line telephone number input field. For more details, see %s.", 'contact-form-7' );
|
226 |
}
|
227 |
|
228 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/text-fields/', 'contact-form-7' ), __( 'Text Fields', 'contact-form-7' ) );
|
229 |
|
230 |
?>
|
231 |
<div class="control-box">
|
modules/textarea.php
CHANGED
@@ -9,7 +9,7 @@ add_action( 'wpcf7_init', 'wpcf7_add_form_tag_textarea' );
|
|
9 |
|
10 |
function wpcf7_add_form_tag_textarea() {
|
11 |
wpcf7_add_form_tag( array( 'textarea', 'textarea*' ),
|
12 |
-
'wpcf7_textarea_form_tag_handler', true );
|
13 |
}
|
14 |
|
15 |
function wpcf7_textarea_form_tag_handler( $tag ) {
|
@@ -137,7 +137,7 @@ function wpcf7_tag_generator_textarea( $contact_form, $args = '' ) {
|
|
137 |
|
138 |
$description = __( "Generate a form-tag for a multi-line text input field. For more details, see %s.", 'contact-form-7' );
|
139 |
|
140 |
-
$desc_link = wpcf7_link( __( '
|
141 |
|
142 |
?>
|
143 |
<div class="control-box">
|
9 |
|
10 |
function wpcf7_add_form_tag_textarea() {
|
11 |
wpcf7_add_form_tag( array( 'textarea', 'textarea*' ),
|
12 |
+
'wpcf7_textarea_form_tag_handler', array( 'name-attr' => true ) );
|
13 |
}
|
14 |
|
15 |
function wpcf7_textarea_form_tag_handler( $tag ) {
|
137 |
|
138 |
$description = __( "Generate a form-tag for a multi-line text input field. For more details, see %s.", 'contact-form-7' );
|
139 |
|
140 |
+
$desc_link = wpcf7_link( __( 'https://contactform7.com/text-fields/', 'contact-form-7' ), __( 'Text Fields', 'contact-form-7' ) );
|
141 |
|
142 |
?>
|
143 |
<div class="control-box">
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Contact Form 7 ===
|
2 |
Contributors: takayukister
|
3 |
-
Donate link:
|
4 |
Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
|
5 |
-
Requires at least: 4.
|
6 |
-
Tested up to: 4.7.
|
7 |
-
Stable tag: 4.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -16,11 +16,11 @@ Contact Form 7 can manage multiple contact forms, plus you can customize the for
|
|
16 |
|
17 |
= Docs & Support =
|
18 |
|
19 |
-
You can find [docs](
|
20 |
|
21 |
= Contact Form 7 Needs Your Support =
|
22 |
|
23 |
-
It is hard to continue development and support for this free plugin without contributions from users like you. If you enjoy using Contact Form 7 and find it useful, please consider [__making a donation__](
|
24 |
|
25 |
= Recommended Plugins =
|
26 |
|
@@ -33,7 +33,7 @@ Jason Hendriks - Postman is a next-generation SMTP Mailer, software that assists
|
|
33 |
|
34 |
= Translations =
|
35 |
|
36 |
-
You can [translate Contact Form 7](
|
37 |
|
38 |
== Installation ==
|
39 |
|
@@ -42,17 +42,17 @@ You can [translate Contact Form 7](http://contactform7.com/translating-contact-f
|
|
42 |
|
43 |
You will find 'Contact' menu in your WordPress admin panel.
|
44 |
|
45 |
-
For basic usage, you can also have a look at the [plugin
|
46 |
|
47 |
== Frequently Asked Questions ==
|
48 |
|
49 |
Do you have questions or issues with Contact Form 7? Use these support channels appropriately.
|
50 |
|
51 |
-
1. [Docs](
|
52 |
-
1. [FAQ](
|
53 |
-
1. [Support Forum](
|
54 |
|
55 |
-
[Support](
|
56 |
|
57 |
== Screenshots ==
|
58 |
|
@@ -60,7 +60,16 @@ Do you have questions or issues with Contact Form 7? Use these support channels
|
|
60 |
|
61 |
== Changelog ==
|
62 |
|
63 |
-
For more information, see [Releases](
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
= 4.6.1 =
|
66 |
|
1 |
=== Contact Form 7 ===
|
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
|
6 |
+
Tested up to: 4.7.2
|
7 |
+
Stable tag: 4.7
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
16 |
|
17 |
= Docs & Support =
|
18 |
|
19 |
+
You can find [docs](https://contactform7.com/docs/), [FAQ](https://contactform7.com/faq/) and more detailed information about Contact Form 7 on [contactform7.com](https://contactform7.com/). If you were unable to find the answer to your question on the FAQ or in any of the documentation, you should check the [support forum](https://wordpress.org/support/plugin/contact-form-7/) on WordPress.org. If you can't locate any topics that pertain to your particular issue, post a new topic for it.
|
20 |
|
21 |
= Contact Form 7 Needs Your Support =
|
22 |
|
23 |
+
It is hard to continue development and support for this free plugin without contributions from users like you. If you enjoy using Contact Form 7 and find it useful, please consider [__making a donation__](https://contactform7.com/donate/). Your donation will help encourage and support the plugin's continued development and better user support.
|
24 |
|
25 |
= Recommended Plugins =
|
26 |
|
33 |
|
34 |
= Translations =
|
35 |
|
36 |
+
You can [translate Contact Form 7](https://contactform7.com/translating-contact-form-7/) on [__translate.wordpress.org__](https://translate.wordpress.org/projects/wp-plugins/contact-form-7).
|
37 |
|
38 |
== Installation ==
|
39 |
|
42 |
|
43 |
You will find 'Contact' menu in your WordPress admin panel.
|
44 |
|
45 |
+
For basic usage, you can also have a look at the [plugin web site](https://contactform7.com/).
|
46 |
|
47 |
== Frequently Asked Questions ==
|
48 |
|
49 |
Do you have questions or issues with Contact Form 7? Use these support channels appropriately.
|
50 |
|
51 |
+
1. [Docs](https://contactform7.com/docs/)
|
52 |
+
1. [FAQ](https://contactform7.com/faq/)
|
53 |
+
1. [Support Forum](https://wordpress.org/support/plugin/contact-form-7/)
|
54 |
|
55 |
+
[Support](https://contactform7.com/support/)
|
56 |
|
57 |
== Screenshots ==
|
58 |
|
60 |
|
61 |
== Changelog ==
|
62 |
|
63 |
+
For more information, see [Releases](https://contactform7.com/category/releases/).
|
64 |
+
|
65 |
+
= 4.7 =
|
66 |
+
|
67 |
+
* Added REST API custom endpoints to manipulate contact form data.
|
68 |
+
* Config Validator: Added test items for field names and attachment file paths.
|
69 |
+
* Added custom DOM events: `wpcf7invalid`, `wpcf7spam`, `wpcf7mailsent`, `wpcf7mailfailed` and `wpcf7submit`.
|
70 |
+
* New action hook: `wpcf7_after_flamingo`.
|
71 |
+
* Added `size` option to `select` and `select*` form-tag types.
|
72 |
+
* Made it possible to use the 3rd parameter of `wpcf7_add_form_tag()` to specify "features" of the form-tag type.
|
73 |
|
74 |
= 4.6.1 =
|
75 |
|
settings.php
CHANGED
@@ -10,11 +10,13 @@ require_once WPCF7_PLUGIN_DIR . '/includes/shortcodes.php';
|
|
10 |
require_once WPCF7_PLUGIN_DIR . '/includes/capabilities.php';
|
11 |
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/mail.php';
|
14 |
require_once WPCF7_PLUGIN_DIR . '/includes/submission.php';
|
15 |
require_once WPCF7_PLUGIN_DIR . '/includes/upgrade.php';
|
16 |
require_once WPCF7_PLUGIN_DIR . '/includes/integration.php';
|
17 |
require_once WPCF7_PLUGIN_DIR . '/includes/config-validator.php';
|
|
|
18 |
|
19 |
if ( is_admin() ) {
|
20 |
require_once WPCF7_PLUGIN_DIR . '/admin/admin.php';
|
@@ -42,7 +44,7 @@ class WPCF7 {
|
|
42 |
self::load_module( 'submit' );
|
43 |
self::load_module( 'text' );
|
44 |
self::load_module( 'textarea' );
|
45 |
-
self::load_module( 'hidden' );
|
46 |
}
|
47 |
|
48 |
protected static function load_module( $mod ) {
|
@@ -133,14 +135,20 @@ function wpcf7_install() {
|
|
133 |
return;
|
134 |
}
|
135 |
|
136 |
-
$contact_form = WPCF7_ContactForm::get_template(
|
137 |
-
|
|
|
|
|
|
|
138 |
|
139 |
$contact_form->save();
|
140 |
|
141 |
-
WPCF7::update_option( 'bulk_validate',
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
146 |
}
|
10 |
require_once WPCF7_PLUGIN_DIR . '/includes/capabilities.php';
|
11 |
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';
|
18 |
require_once WPCF7_PLUGIN_DIR . '/includes/config-validator.php';
|
19 |
+
require_once WPCF7_PLUGIN_DIR . '/includes/rest-api.php';
|
20 |
|
21 |
if ( is_admin() ) {
|
22 |
require_once WPCF7_PLUGIN_DIR . '/admin/admin.php';
|
44 |
self::load_module( 'submit' );
|
45 |
self::load_module( 'text' );
|
46 |
self::load_module( 'textarea' );
|
47 |
+
self::load_module( 'hidden' );
|
48 |
}
|
49 |
|
50 |
protected static function load_module( $mod ) {
|
135 |
return;
|
136 |
}
|
137 |
|
138 |
+
$contact_form = WPCF7_ContactForm::get_template(
|
139 |
+
array(
|
140 |
+
'title' => sprintf( __( 'Contact form %d', 'contact-form-7' ), 1 ),
|
141 |
+
)
|
142 |
+
);
|
143 |
|
144 |
$contact_form->save();
|
145 |
|
146 |
+
WPCF7::update_option( 'bulk_validate',
|
147 |
+
array(
|
148 |
+
'timestamp' => current_time( 'timestamp' ),
|
149 |
+
'version' => WPCF7_VERSION,
|
150 |
+
'count_valid' => 1,
|
151 |
+
'count_invalid' => 0,
|
152 |
+
)
|
153 |
+
);
|
154 |
}
|
uninstall.php
CHANGED
@@ -9,10 +9,13 @@ function wpcf7_delete_plugin() {
|
|
9 |
|
10 |
delete_option( 'wpcf7' );
|
11 |
|
12 |
-
$posts = get_posts(
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
foreach ( $posts as $post ) {
|
18 |
wp_delete_post( $post->ID, true );
|
9 |
|
10 |
delete_option( 'wpcf7' );
|
11 |
|
12 |
+
$posts = get_posts(
|
13 |
+
array(
|
14 |
+
'numberposts' => -1,
|
15 |
+
'post_type' => 'wpcf7_contact_form',
|
16 |
+
'post_status' => 'any',
|
17 |
+
)
|
18 |
+
);
|
19 |
|
20 |
foreach ( $posts as $post ) {
|
21 |
wp_delete_post( $post->ID, true );
|
wp-contact-form-7.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Contact Form 7
|
4 |
-
Plugin URI:
|
5 |
Description: Just another contact form plugin. Simple but flexible.
|
6 |
Author: Takayuki Miyoshi
|
7 |
Author URI: http://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
-
Version: 4.
|
11 |
*/
|
12 |
|
13 |
-
define( 'WPCF7_VERSION', '4.
|
14 |
|
15 |
-
define( 'WPCF7_REQUIRED_WP_VERSION', '4.
|
16 |
|
17 |
define( 'WPCF7_PLUGIN', __FILE__ );
|
18 |
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Contact Form 7
|
4 |
+
Plugin URI: https://contactform7.com/
|
5 |
Description: Just another contact form plugin. Simple but flexible.
|
6 |
Author: Takayuki Miyoshi
|
7 |
Author URI: http://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
+
Version: 4.7
|
11 |
*/
|
12 |
|
13 |
+
define( 'WPCF7_VERSION', '4.7' );
|
14 |
|
15 |
+
define( 'WPCF7_REQUIRED_WP_VERSION', '4.6' );
|
16 |
|
17 |
define( 'WPCF7_PLUGIN', __FILE__ );
|
18 |
|